What is “X-Content-Type-Options=nosniff”?

It prevents the browser from doing MIME-type sniffing. Most browsers are now respecting this header, including Chrome/Chromium, Edge, IE >= 8.0, Firefox >= 50 and Opera >= 13. See : https://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx?Redirected=true Sending the new X-Content-Type-Options response header with the value nosniff will prevent Internet Explorer from MIME-sniffing a response away from the declared content-type. EDIT: … Read more

How do I access the HTTP request header fields via JavaScript?

If you want to access referrer and user-agent, those are available to client-side Javascript, but not by accessing the headers directly. To retrieve the referrer, use document.referrer. To access the user-agent, use navigator.userAgent. As others have indicated, the HTTP headers are not available, but you specifically asked about the referer and user-agent, which are available … Read more

How to get the file size from http headers

Yes, assuming the HTTP server you’re talking to supports/allows this: public long GetFileSize(string url) { long result = -1; System.Net.WebRequest req = System.Net.WebRequest.Create(url); req.Method = “HEAD”; using (System.Net.WebResponse resp = req.GetResponse()) { if (long.TryParse(resp.Headers.Get(“Content-Length”), out long ContentLength)) { result = ContentLength; } } return result; } If using the HEAD method is not allowed, or … Read more

Set HTTP header for one request

There’s a headers parameter in the config object you pass to $http for per-call headers: $http({method: ‘GET’, url: ‘www.google.com/someapi’, headers: { ‘Authorization’: ‘Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==’} }); Or with the shortcut method: $http.get(‘www.google.com/someapi’, { headers: {‘Authorization’: ‘Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==’} }); The list of the valid parameters is available in the $http service documentation.

Best HTTP Authorization header type for JWT

The best HTTP header for your client to send an access token (JWT or any other token) is the Authorization header with the Bearer authentication scheme. This scheme is described by the RFC6750. Example: GET /resource HTTP/1.1 Host: server.example.com Authorization: Bearer eyJhbGciOiJIUzI1NiIXVCJ9TJV…r7E20RMHrHDcEfxjoYZgeFONFh7HgQ If you need stronger security protection, you may also consider the following IETF … Read more