cmiles74 / bishop

A Webmachine-like library for Clojure
Other
95 stars 10 forks source link

When a request doesn’t include the Accept header, the response does not include a representation #16

Closed aviflax closed 12 years ago

aviflax commented 12 years ago

I think it’d be better to simply use the first specified representation function as the default.

$ curl -v -H "Accept:" http://localhost:3000/
* About to connect() to localhost port 3000 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 3000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
> 
< HTTP/1.1 200 OK
< Date: Wed, 15 Aug 2012 03:35:32 GMT
< Vary: accept-charset
< Content-Type: text/plain;charset=UTF-8
< Content-Length: 0
< Server: Jetty(7.6.1.v20120215)
< 
* Connection #0 to host localhost left intact
* Closing connection #0
cmiles74 commented 12 years ago

We should provide something back to the client, a 200 with no content is clearly wrong. I've been thinking about this a little bit; how about we interpret a missing or empty "Accept" header as "/" (accept any content). In effect, the first representation would be provided back to the client.

cmiles74 commented 12 years ago

An empty "Accept" header should be treated as if the client finds no content types acceptable and a 406 "Not Acceptable" should be returned. The root problem was that the function that checked this header wasn't looking for an empty set but rather a nil or false. This has been fixed in the 1.1.6 release.