influencia0406 / oauth-signpost

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

Cannot sign post with httpurlconnection #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a httpurlconnection for posting to a url endpoint
2. the getMessagePayload() method on httprequestadaptor will return null
3. SignatureBaseString.java will be used when signing the request. the
following lines of code are executed:

        if (contentType != null && contentType.equals(OAuth.FORM_ENCODED)) {
            InputStream payload = request.getMessagePayload();
            parameters.addAll(OAuth.decodeForm(payload));
        }

payload will be null as described in #2, and will throw a null error when
OAuth.decodeForm(payload) is called. 

What is the expected output? What do you see instead?
A null pointer will not be thrown

What version of the product are you using? On what operating system?
1.1

Please provide any additional information below.
More code available upon request.

Example below of signing post request httpurlconnection

            HttpURLConnection request = (HttpURLConnection)
url.openConnection();     

            request.setRequestMethod("POST");
            request.setAllowUserInteraction(false); // you may not ask the user
            request.setDoInput(true);
            request.setDoOutput(true);
            request.setUseCaches(false);
            // the Content-type should be default, but we set it anyway
            request.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
            // the content-length should not be necessary, but we're cautious
            request.setRequestProperty( "Content-length",
Integer.toString(queryParams.length()));

            consumer.sign(request);

            //get the output stream to POST our form data
            OutputStreamWriter wr = new
OutputStreamWriter(request.getOutputStream());
            wr.write(queryParams);
            wr.flush();
            wr.close();

Original issue reported on code.google.com by dwt...@gmail.com on 2 Oct 2009 at 12:55

GoogleCodeExporter commented 8 years ago
This is a duplicate of Issue 15.

Original comment by m.kaepp...@gmail.com on 8 Oct 2009 at 7:53