Auto-detect available port when running headless tests

By default the test server tried to run on port 3000, which would fail
with a misleading message if something else happened to occupy that port
on the system (such as a Rails app).

Now start incrementing the port number from 3900 and stop when the port
is found to be available.
Merge pull request #27 from github/test-port

Auto-detect available port when running headless tests
Uppercase the HTTP method name

This fixes PUT/DELETE for IE 9 and PATCH for Node.js.
Normalize capitalization of HTTP methods per fetch spec

Now only the whitelisted method names get normalized by uppercasing and
the rest are left untouched since HTTP method names in general are
case-sensitive.

In tests we must use `PATCH` (uppercase) because Node.js server doesn't
support `patch` (lowercase).
Compensate for the broken PATCH support in PhantomJS

PhantomJS doesn't seem to send request body for PATCH:
https://github.com/ariya/phantomjs/issues/11384
Fix test suite CSS for IE

By default, all static files served from the test server were
"text/plain". IE auto-detects HTML and JavaScript content as such, but
refuses to display the style sheet until it is served as "text/css".
Fix sending requests with empty body such as DELETE in IE

If the body passed to `xhr.send()` is `undefined`, the text sent would
literally be "undefined" on IE.
Fix test that reads "Date" header on IE

IE caches xhr responses pretty aggressively and after restoring the
previous response from cache, it blanks out the "Date" header (probably
by design). The solution for this test is to use a cache-busting query
parameter.
Fix promise being rejected on IE 9 when server response is invalid

Reject all HTTP codes that are not in the 100..599 range.

When an empty reply is received from the server, `xhr.onerror` callback
should get triggered. IE 9, however, triggers the `onload` callback with
status code 12152 that stands for:

    ERROR_HTTP_INVALID_SERVER_RESPONSE
    The server response could not be parsed.

http://support.microsoft.com/kb/193625
Fixes 204 No Content responses for IE 9

IE 9 fails on 204s with error code 1223
http://www.enhanceie.com/ie/bugs.asp

Rewrite the code back to 204. Note: response headers remain unavailable
in this case. This was fixed in IE 10.