0

I have an app here that sends out an HTTP PUT to a webserver. The code looks like this:

  URL url = new URL(urlStr + "?" + encodedParameters);
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod("PUT");
  connection.setRequestProperty("Content-Length", "0");

When I try this on Android 2.1, I end up getting back a 411 error ("Length Required").

On Android 2.3.3 and up I was getting this same 411 error back until I added that last "Content-Length" property. But it's still happening on Android 2.1.

Anyone have an idea what might be going on here?

Cruinh
  • 3,611
  • 4
  • 38
  • 45

1 Answers1

0

Not sure if this will work, but it may be worth trying to set "Content-Length" like below:

connection.setRequestProperty("Content-Length", Integer.toString(encodedParameters.getBytes().length));
marcbest
  • 1,600
  • 1
  • 10
  • 15