mgomes / api_auth

HMAC authentication for Rails and HTTP Clients
MIT License
480 stars 147 forks source link

Request driver for multipart-post #47

Closed adamcrown closed 10 years ago

adamcrown commented 10 years ago

Although multipart-post uses Net::HTTP the Content-MD5 isn't properly calculated when files are attached because multipart-post uses body_stream instead of body. This driver should solve that.

kjg commented 10 years ago

Is it possible for someone to set a body_stream even when not using multipart-post? If so maybe the net_http adapter should just check both body and body_stream. What do you think?

adamcrown commented 10 years ago

There is a HTTPGenericRequest#body_stream it seems fairly undocumented and unused. A google search doesn't turn up a whole lot. But I'd be happy to submit another pull request to handle that. It would probably be a much smaller change to the codebase.

kjg commented 10 years ago

That would be great. If I'm looking at multipart-post code correctly, it looks like it is just relying on the default behavior of HTTPGenericRequest#body_stream and just adding in features to handle setting Content-Type and boundaries correctly.

I think adding it to the net_http adapter would thus add the most robust support (even if the feature isn't used often outside of multipart-post).

adamcrown commented 10 years ago

Posted a new pull request #49