Special Characters in Content-Disposition filename

Firefox, MSIE (starting with version 9), Opera, Konq and Chrome support; MSIE8 and Safari not support; others support is unknown – the encoding defined in RFC 5987. Note that in Content-Disposition: attachment; filename*=UTF-8”weird%20%23%20%80%20%3D%20%7B%20%7D%20%3B%20filename.txt you got the encoding for the Euro character wrong; it’s unicode code point is not %80, fixing this should make it work … Read more

Using Json string in the Http Header

Yes, you may use JSON in HTTP headers, given some limitations. According to the HTTP spec, your header field-body may only contain visible ASCII characters, tab, and space. Since many JSON encoders (e.g. json_encode in PHP) will encode invisible or non-ASCII characters (e.g. “é” becomes “\u00e9”), you often don’t need to worry about this. Check … Read more

HttpClient Request like browser

Here you go – note you have to decompress the gzip encoded-result you get back as per mleroy: private static readonly HttpClient _HttpClient = new HttpClient(); private static async Task<string> GetResponse(string url) { using (var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url))) { request.Headers.TryAddWithoutValidation(“Accept”, “text/html,application/xhtml+xml,application/xml”); request.Headers.TryAddWithoutValidation(“Accept-Encoding”, “gzip, deflate”); request.Headers.TryAddWithoutValidation(“User-Agent”, “Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 … Read more

How to get the name of a file downloaded with Angular $http?

It may be worth mentioning that in order to get the file name from the HTTP headers, extracting the Content-Disposition header is not enough. You still need to obtain the filename property from this header value. Example of header value returned: attachment; filename=”myFileName.pdf”. The function below will extract filename=”myFileName.pdf”, then extract “myFileName.pdf” and finally remove … Read more

HTTP Status 202 – how to provide information about async request completion?

Definitely do not abuse existing HTTP headers for this. Since it’s your own server, you get to define what the response looks like. You can (and should) pick whatever response works best for the intended recipient of this information and return the actual information in the response body. For example, if you are only interested … Read more

Difference between X-Forwarded-For and X-Real-IP headers

What is the difference between these headers? Did you check the $proxy_add_x_forwarded_for variable documentation? the X-Forwarded-For client request header field with the $remote_addr variable appended to it, separated by a comma. If the X-Forwarded-For field is not present in the client request header, the $proxy_add_x_forwarded_for variable is equal to the $remote_addr variable. If the incoming … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)