Human readable format for http headers with tcpdump

Here’s a one-liner I came up with for displaying request and response HTTP headers using tcpdump (which should work for your case too): sudo tcpdump -A -s 10240 ‘tcp port 4080 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’ | egrep –line-buffered “^……..(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: ” | sed -r ‘s/^……..(GET |HTTP\/|POST |HEAD )/\n\1/g’ It … Read more

Difference between `curl -I` and `curl -X HEAD`

It seems the difference has to do with the Content-Length header and how it is treated by both commands. But before going into that, curl -X HEAD does not give any output because, by default, curl does not print headers if switch -i is not provided (not needed on -I though). In any case, curl … 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. It cannot be stressed enough that this is a transport … Read more

Are HTTP headers case-sensitive?

Header names are not case sensitive. From RFC 2616 – “Hypertext Transfer Protocol — HTTP/1.1”, Section 4.2, “Message Headers”: Each header field consists of a name followed by a colon (“:”) and the field value. Field names are case-insensitive. The updating RFC 7230 does not list any changes from RFC 2616 at this part.

WebException (Status: Protocol Error)

Your server is returning HTTP 1201 which is not a standard status code. WebClient will fail with an exception when facing a non-successful status code (or an unrecognized one, in your case). I encorauge you to use the new HttpClient class if you can: If you have to do it synchronously:

SON Post with Customized HTTPHeader Field

What you posted has a syntax error, but it makes no difference as you cannot pass HTTP headers via $.post(). Provided you’re on jQuery version >= 1.5, switch to $.ajax() and pass the headers (docs) option. (If you’re on an older version of jQuery, I will show you how to do it via the beforeSend … Read more

Proper MIME media type for PDF files

The standard Media Type (formerly known as MIME types) is application/pdf. The assignment is defined in RFC 3778, The application/pdf Media Type, referenced from the Media Types registry. Media Types are controlled by a standards body, The Internet Assigned Numbers Authority (IANA). This is the same organization that manages the root name servers and the IP address space. The use … Read more

What’s the point of the X-Requested-With header?

A good reason is for security – this can prevent CSRF attacks because this header cannot be added to the AJAX request cross domain without the consent of the server via CORS. Only the following headers are allowed across origins: Accept Accept-Language Content-Language Last-Event-ID Content-Type any others cause a “pre-flight” request to be issued in CORS supported browsers. … Read more