travis-ci/travis-api — pull request #50 by drogus (2013-02-18 17:09:16+00:00)
Title: Accept header fixes

This pull request contains a few fixes for a way we handle `Accept` header:

* we allow to pass multiple content types, previously we just processed the first one
* if we can't respond with requested format, 406 response will be returned
* the API version is taken from each of the content types, so one can send `Accept: application/json; version=1; application/json; version=2` and if version 1 is not available for given resource, we will properly return version 2
* we parse params from content types
* version can be passed as a param (as shown above)
* logs can be requested in chunked version with `chunked=true`, it will succeed if log is not yet aggregated

One of the things that I would like to add, but which is not crucial for what we want to achieve with this, is returning content type with params. Right now if you send Accept header looking like `Accept: application/json; chunked=true, application/json`, we will respond with `Content-Type: application/json` regardless which of those versions is accepted. Ideally we should respond with `Content-Type: application/json; chunked=true` if we returned chunked long, so client can check the header instead of checking what does the body contain.