I want to check if the URL of a large file exists. I'm using the code below but it is too slow:
public static bool TryGet(string url) { try { GetHttpResponseHeaders(url); return true; } catch (WebException) { } return false; } public static Dictionary<string, string> GetHttpResponseHeaders(string url) { Dictionary<string, string> headers = new Dictionary<string, string>(); WebRequest webRequest = HttpWebRequest.Create(url); using (WebResponse webResponse = webRequest.GetResponse()) { foreach (string header in webResponse.Headers) { headers.Add(header, webResponse.Headers[header]); } } return headers; }
Another example of using a custom HTTP header would be to implement the X-Pull header. You can use this custom header for a variety of purposes including rate limiting bandwidth on your origin server, restricting CDN traffic, creating custom logic on your origin server, etc.
go to the network tab and right click the first item and click copy as cURL (this is how you will get the header size. Then go to terminal and do your curl command curl ... -w '%{size_request} %{size_upload}' which will print out the request size at the end.
It is a request type header. The Accept header is used to inform the server by the client that which content type is understandable by the client expressed as MIME-types. Accept-charset. It is a request type header. This header is used to indicate what character set are acceptable for the response from the server.
You need to set:
webRequest.Method = "HEAD";
This way the server will respond with the header information only (no content). This is also useful to check if the server accepts certain operations (i.e. compressed data etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With