evantahler/actionHero — pull request #252 by evantahler (2013-11-17 00:14:07+00:00)
Title: support for OPTIONS and TRACE HTTP methods

actionHero should respond to OPTIONS and TRACE HTTP methods properly.
Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

- OPTIONS will always return a header for `Access-Control-Allow-Methods` and `Access-Control-Allow-Origin`, even if they are not set in `config.js`. They will default to `PUT, GET, POST, DELETE, OPTIONS, TRACE` and `*` accordingly
- TRACE will return with the parsed URL and Form data posted to the server. actionHero will ignore params that are invalid/ignored in the response. The response will be formatted into JSON
- Update the default `config.js` to include OPTIONS and TRACE as allowed HTTP methods
- Add some tests

## OPTIONS

```bash
> curl localhost:8080 -X OPTIONS -v

---------------------------------------------------------

* Connected to localhost (127.0.0.1) port 8080 (#0)
> OPTIONS / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 0
< Access-Control-Allow-Headers: Content-Type
< Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS, TRACE
< Access-Control-Allow-Origin: *
< X-Powered-By: actionHero API
< Content-Type: application/json
< Transfer-Encoding: Chunked
< Set-Cookie: sessionID=f5ba2909c8c13645038e9807c2f9c823c179f12c
< Date: Sun, 17 Nov 2013 00:10:06 GMT
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
```

## TRACE

```bash
> curl "localhost:8080/api/someAction?key=myKey" -X TRACE -v

---------------------------------------------------------

* Connected to localhost (127.0.0.1) port 8080 (#0)
> TRACE /api/someAction?key=myKey HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 155
< Access-Control-Allow-Headers: Content-Type
< Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS, TRACE
< Access-Control-Allow-Origin: *
< X-Powered-By: actionHero API
< Content-Type: application/json
< Transfer-Encoding: Chunked
< Set-Cookie: sessionID=9fd990a33b9942b6801a090bf2a170a425afa617
< Date: Sun, 17 Nov 2013 00:10:36 GMT
< Connection: keep-alive
<
{
"id": "9fd990a33b9942b6801a090bf2a170a425afa617",
"remoteIP": "127.0.0.1",
"receivedParams": {
"key": "myKey",
"action": "someAction"
}
* Connection #0 to host localhost left intact
```