problems with 'no Accept header' request

Brian Candler B.Candler at
Fri Aug 31 01:48:10 EDT 2007

On Thu, Aug 30, 2007 at 06:40:48PM -0400, Matt Aimonetti wrote:
>    I'm trying to setup a Merb cluster + attachment_fu to handle uploads
>    for a client's Rails app.
>    I'm using Flash to upload the files and I realized that Merb was
>    giving me an error for each upload. It turns out that Flash doesn't
>    seem to send an Accept header and Merb's responder crashes because
>    it's trying to split the missing Accept header.
>    responder.rb line 37
>            def initialize(accept_header, params={})
>     accept_header
>              @accepts = Responder.parse(accept_header)
>              @params = params
>              @stack  = {}
>            end
>    @accepts seems to be later on used in negotiate_content() l84,
>    negotiate_by_format() l92, negotiate_by_accept_header l103
>    What's the proper way of dealing with this problem?

RFC 2616:

"  If no Accept header field is present, then it is assumed that the
   client accepts all media types."

So I think you could make Responser.parse return [:all] in the event of nil
accept_header being passed in.

  return [:all] unless accept_header


More information about the Merb-devel mailing list