JBesaw29 / oauth-signpost

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

workaround for java.net POST #48

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Would be nice to add this static method to OAuthConsumer or some other 
class, it's a quick hack to allow POST url-encoded while using java.net
( it can also be used in user code )

    public static void signAndSend(OAuthConsumer consumer,       
            HttpURLConnection req, final byte[] payload) 
        throws ... 
    {
        HttpRequest spReq = new HttpURLConnectionRequestAdapter(req) {
            public InputStream getMessagePayload() {
                return new ByteArrayInputStream(payload);
            }
        };

        consumer.sign(spReq);

        OutputStream os = req.getOutputStream();
        os.write(payload);
        os.close();
    }

A better option would be to refactor the interfaces so signAndSend() with 
payload is common to all http client wrappers. 

Original issue reported on code.google.com by costin on 27 May 2010 at 5:14

GoogleCodeExporter commented 8 years ago
Good idea.

Original comment by m.kaepp...@gmail.com on 27 May 2010 at 10:30

GoogleCodeExporter commented 8 years ago
I submitted a proposed implementation for this in defect #58.  Sorry for the 
duplicate.  Good to see it's not difficult to extend w/o modifying the current 
Signpost codebase though.

Original comment by tmnich...@gmail.com on 10 Sep 2010 at 11:31