inf0rmer/blanket

Content-Type

Closed this issue · 4 comments

Hi, I think the Content-Type header is not being used because I am getting malformed syntax from an API with Blanket, and doing with Net::HTTP it's working. Can you verify that?

Thanks!

Hi! I set up a small local server and I could get Content-Type to work, however I found a small bug. HTTParty can not take hashes with symbolized keys (and in fact crashes if you try to use them) so maybe that's what was happening to you?

I've fixed it in #19, can you check if that works for you?

Thanks for the fast reply.
I was already using strings in the header, like this:

API = Blanket.wrap('https://api.bla.com', headers: { 'Content-Type' => 'application/json', 'Authorization' => "#{ActionController::HttpAuthentication::Basic.encode_credentials(ENV['SECRET_KEY'], '')}" })

I am still getting malformed syntax, I think that the problem persists.

Do you know how to activate the verbose mode on HTTParty?

Hm, that is weird. You can use HTTParty's verbose mode with the CLI utility only, as far as I know:

httparty http://localhost:4000 -v -H Content-Type:application/json

GET http://localhost:4000
Content-Type: application/json

200 OK
content-type: text/html
date: Tue, 10 Feb 2015 12:48:56 GMT
connection: close
transfer-encoding: chunked

"<!DOCTYPE html><html><head><title>Hello World Page</title></head><body>Hello World!</body></html>"

I'm using a small Node JS server to test this, logging the request headers to the console, and it works the same when I use it from Blanket (using your example, without the Auth header) and from the HTTParty CLI utility. Can you inspect the headers on the API side?

I think the Content-Type header it's OK, but for some reason the request is malformed by the API.
I cannot inspect the API because it's a service that I am using, I will just use Net:HTTP for now.
Thanks for your time bruno!