demandforce/rack-oauth2-server — Issue #30: Rack::Lint::LintError: No Content-Type header found
Author: renatosnrg
Created: 2012-02-10 20:01:26+00:00
State: open

Instead of having a "401 Unauthorized" response when oauth is not authenticated (oauth.no_access), it's being raised a "500 Internal Server Error" with "Rack::Lint::LintError: No Content-Type header found" exception.

I had this problem using Sinatra in development environment and running a Rack server (rackup). It happens because rackup servers automatically add Rack::Lint in development mode.

To ensure Rack protocol is being followed, there must be a Content-type header in all responses, except when the status is 1xx, 204 or 304.

Following this idea, rack-oauth2-server needs to add a Content-type header when returns an unauthorized response:

return [401, { "Content-Type"=>"text/plain", "WWW-Authenticate"=>challenge }, [error && error.message || ""]]