AlvAChristina / oauth-signpost

Automatically exported from code.google.com/p/oauth-signpost
0 stars 0 forks source link

POST support for DefaultOAuthConsumer #58

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is an enhancement request to allow POST signing for HTTPUrlConnections:

Presuming that whomever is using HttpURLConnection is creating an 
application-www-urlencoded POST body, they should be able to set that 
information when signing the request (the body will more often be a String than 
actual streaming data.)  I'd like to extend HttpURLConnectionRequest (and 
possibly DefaultOAuthConsumer) to handle this case.

The simplest implementation is to overload the HttpURLConnectionRequest 
constructor to accept a connection and an inputstream.  You'd have to assume 
the inputstream is reset-able (like a ByteArrayInputStream.)  Then of course 
change getMessagePayload() to return the stream.  More complex examples would 
involve constructors that accept a reader, string, etc but I don't think that's 
strictly necessary; you can require the user to move whatever content into a 
ByteArrayInputStream.  Going further, if you don't want to require your users 
to directly create an HttpURLConnectionRequest, you'd need a new method: 
DefaultOAuthConsumer.sign(HttpRequest, InputStream) so the content can be 
passed with the request, and then create a wrap(Object,InputStream) method as 
well.

I'm requesting this specifically so I can support OAuth in HTTPBuilder.

But in short, I've tried it; it works :)

Patch attached.

Original issue reported on code.google.com by tmnich...@gmail.com on 9 Sep 2010 at 12:50

Attachments:

GoogleCodeExporter commented 8 years ago
This seems like a great fix.  Is there a jar with these patches built into it 
or could someone post the most recent version.  I am implementing the oAuth 
signpost with Bill's CF wrapper and want to be able to post files to google 
apis with multipart data and have still not had success but it seems this 
solves it.

Thanks so very very much
Matt

Original comment by turntree...@gmail.com on 6 Apr 2011 at 3:10