HTTP headers and verbs are case-sensitive

by benl

Reminder to self: HTTP headers and verbs are case-sensitive. Oh yes, big gotcha.

I’ve been working on a .NET Windows Service which consumes a RESTful service hosted via Rails. During the development/test cycle I’ve been pointing my tests to a mocked service hosted locally under IIS. Upon testing against the real REST URIs I ran into a strange issue of a hanging System.Net.HttpWebRequest.

The issue was in sending the verbs in lowercase and not adhering to the HTTP RFC, which IIS rather unhelpfully doesn’t adhere to either. See, IIS will respond to verbs in lowercase, which I guess in some cases, if you don’t leave the wonderful Windows world of case-insensitivity perhaps, can be helpful? Apache (on Linux at least, haven’t tried on Windows) isn’t so flexible which is definitely a Good Thing… 🙂

The sad thing about this is that I’d ran into this same issue a few years back, but conveniently only remembered after I’d spent a couple of hours debugging this one!