How does Content-Security-Policy work with X-Frame-Options?

The frame-src CSP directive (which is deprecated and replaced by child-src) determines what sources can be used in a frame on a page. The X-Frame-Options response header, on the other hand, determines what other pages can use that page in an iframe. In your case, http://a.com with X-Frame-Options: DENY indicates that no other page can … Read more

What are the possible reasons to get APNs responses BadDeviceToken or Unregistered?

As you’ve quoted from Table 8-6 in the APNS documentation, there are two possible causes for the error: That the device token is invalid That the device token does not match the environment If it is the first case, make sure that the iOS app registers the device for remote notifications every single time that … Read more

When looking at the differences between X-Auth-Token vs Authorization headers, which is preferred?

Authorization is the primary header used by clients to authenticate against peers in HTTP as foreseen in RFC 7235. It is often linked to the Basic authentication scheme as per RFC 7617, but that is not a given. The Basic scheme allows clients to provide a username-password-pair separated by a colon (:) coded in Base64. … Read more

How to add header data in XMLHttpRequest when using formdata?

Your error InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable appears because you must call setRequestHeader after calling open. Simply move your setRequestHeader line below your open line (but before send): xmlhttp.open(“POST”, url); xmlhttp.setRequestHeader(“x-filename”, photoId); xmlhttp.send(formData);

Java – How to find the redirected url of a url?

Simply call getUrl() on URLConnection instance after calling getInputStream(): URLConnection con = new URL( url ).openConnection(); System.out.println( “orignal url: ” + con.getURL() ); con.connect(); System.out.println( “connected url: ” + con.getURL() ); InputStream is = con.getInputStream(); System.out.println( “redirected url: ” + con.getURL() ); is.close(); If you need to know whether the redirection happened before actually getting … 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