Monday, April 05, 2010

lib/webrat/adapters/mechanize.rb ignores http headers

Looks webrat ignores http headers (when we tried to manually set http headers), for example
def rating
   url_path = '/rating';# + id
   header "Accept", "text/xml"
   visit(
       @url + url_path,
       :post
   )
end
So i take a look closer into lib/webrat/adapters/mechanize.rb, and i saw this line of code inside method 'post'
@response = mechanize.post(url, post_data)
, i think this is the problem.

I change the line with
@response = mechanize.post(url, post_data, headers_argument_not_used)

And now looks everything is okay (i hope).

No comments: