Standard for adding multiple values of a single HTTP Header to a request or response

You’ll want to take a look at the HTTP spec RFC 2616 where it says: Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple … Read more

How to prevent my site page to be loaded via 3rd party site frame of iFrame

You cannot check it from the server’s side, but you can use javascript to detect it after the page has loaded. Compare top and self, if they’re not identical, you are in a frame. Additionally, some modern browsers respect the X-FRAME-OPTIONS header, that can have two values: DENY – prevents the page from being rendered … Read more

Check if PHP-page is accessed from an iOS device

Use the user agent from $_SERVER[‘HTTP_USER_AGENT’], and for simple detection you can use this script: <?php //Detect special conditions devices $iPod = stripos($_SERVER[‘HTTP_USER_AGENT’],”iPod”); $iPhone = stripos($_SERVER[‘HTTP_USER_AGENT’],”iPhone”); $iPad = stripos($_SERVER[‘HTTP_USER_AGENT’],”iPad”); $Android = stripos($_SERVER[‘HTTP_USER_AGENT’],”Android”); $webOS = stripos($_SERVER[‘HTTP_USER_AGENT’],”webOS”); //do something with this information if( $iPod || $iPhone ){ //browser reported as an iPhone/iPod touch — do something here … Read more

Are there any constants for the default HTTP headers?

I found this question while trying to discover the same thing: where are the header name constants as strings? In ASP.NET Core, Microsoft.Net.Http.Headers.HeaderNames is the class that saved me. public static class HeaderNames { public const string Accept = “Accept”; public const string AcceptCharset = “Accept-Charset”; public const string AcceptEncoding = “Accept-Encoding”; public const string … Read more

Why do I get “Cannot redirect after HTTP headers have been sent” when I call Response.Redirect()?

According to the MSDN documentation for Response.Redirect(string url), it will throw an HttpException when “a redirection is attempted after the HTTP headers have been sent”. Since Response.Redirect(string url) uses the Http “Location” response header (http://en.wikipedia.org/wiki/HTTP_headers#Responses), calling it will cause the headers to be sent to the client. This means that if you call it a … Read more

HTTP Range header

As Wrikken suggested, it’s a valid request. It’s also quite common when the client is requesting media or resuming a download. A client will often test to see if the server handles ranged requests other than just looking for an Accept-Ranges response. Chrome always sends a Range: bytes=0- with its first GET request for a … Read more

Adding a custom header to HTTP request using angular.js

I took what you had, and added another X-Testing header var config = {headers: { ‘Authorization’: ‘Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==’, ‘Accept’: ‘application/json;odata=verbose’, “X-Testing” : “testing” } }; $http.get(“/test”, config); And in the Chrome network tab, I see them being sent. GET /test HTTP/1.1 Host: localhost:3000 Connection: keep-alive Accept: application/json;odata=verbose X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS … Read more