That's not right, I'm afraid (unless I'm misunderstanding you.) POST 
requests for REST APIs generally have a body that contains their content.
I had a dig into the Google IO 2012 POST request code and it seems like it 
does some odd things.

  HttpURLConnection conn = null;
>
>         try {
>
>             conn = (HttpURLConnection) url.openConnection();
>
>             conn.setDoOutput(true);
>
>             conn.setUseCaches(false);
>
>             conn.setChunkedStreamingMode(0);
>
>             conn.setRequestMethod("POST");
>
>             conn.setRequestProperty("Content-Type",
>
>                     "application/x-www-form-urlencoded;charset=UTF-8");
>
>             conn.setRequestProperty("Content-Length",
>
>                     Integer.toString(body.length()));
>
>             // post the request
>
>             OutputStream out = conn.getOutputStream();
>
>             out.write(body.getBytes());
>
>             out.close();
>
>             // handle the response
>
>             int status = conn.getResponseCode();
>
>             if (status != 200) {
>
>                 throw new IOException("Post failed with error code " + 
>> status);
>
>             }
>
>         } finally {
>
>
It sets a specific request method after already setting doOutput (which, 
apparently, forces the request to use POST) and sets a fixed-length HTTP 
header while still using chunked request mode. Which doesn't make a large 
amount of sense. 
I am at a loss and wondering if it's something to do with my internet 
service using some kind of proxy that I'm not aware of and the 
HttpUrlConnection failing to redirect somehow the first time. ('curl'ing 
the same request works fine.) 

 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to