intridea/grape — pull request #343 by gustavosaume (2013-02-22 01:06:52+00:00)
Title: add Content-Type header to the 405 response

Rack throws Rack::Lint::LintError after calling an undefined method for an endpoint, it expects a Content-Type in the response.

Expected response for a PUT request to a defined endpoint that doesn't allow PUT:
```text
HTTP/1.1 405 Method Not Allowed
Allow: OPTIONS, GET, HEAD
Cache-Control: no-cache
Connection: close
Server: thin 1.5.0 codename Knife
Transfer-Encoding: Identity
```

Current response:
```text
HTTP/1.1 500 Internal Server Error
Content-Length: 90362
Content-Type: text/html
Connection: close
Server: thin 1.5.0 codename Knife
```
Stack trace
```text
gems/rack-1.4.5/lib/rack/lint.rb:19:in `assert'
gems/rack-1.4.5/lib/rack/lint.rb:476:in `check_content_type'
gems/rack-1.4.5/lib/rack/lint.rb:54:in `_call'
gems/rack-1.4.5/lib/rack/lint.rb:36:in `call'
gems/rack-1.4.5/lib/rack/showexceptions.rb:24:in `call'
gems/rack-1.4.5/lib/rack/commonlogger.rb:33:in `call'
gems/sinatra-1.3.4/lib/sinatra/base.rb:161:in `call'
gems/rack-1.4.5/lib/rack/chunked.rb:43:in `call'
gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
gems/thin-1.5.0/lib/thin/connection.rb:81:in `block in pre_process'
gems/thin-1.5.0/lib/thin/connection.rb:79:in `catch'
gems/thin-1.5.0/lib/thin/connection.rb:79:in `pre_process'
gems/thin-1.5.0/lib/thin/connection.rb:54:in `process'
gems/thin-1.5.0/lib/thin/connection.rb:39:in `receive_data'
gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
gems/thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
gems/thin-1.5.0/lib/thin/server.rb:159:in `start'
gems/rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
gems/rack-1.4.5/lib/rack/server.rb:137:in `start'
gems/rack-1.4.5/bin/rackup:4:in `'
bin/rackup:19:in `load'
bin/rackup:19:in `

'
bin/ruby_noexec_wrapper:14:in `eval'
bin/ruby_noexec_wrapper:14:in `

'
```