How do I explicitly disable chunked streaming mode for HTTP connections in Android?
问题 I'm targeting a REST web service from Android 4.0 using HttpsURLConnection . This works fine unless I try to POST something. This is the relevant code section: connection.setDoOutput(true); connection.setChunkedStreamingMode(0); ByteArrayOutputStream out = new ByteArrayOutputStream(); serializeObjectToStream(out, object); byte[] array = out.toByteArray(); connection.getOutputStream().write(array, 0, array.length); This throws the following exception: java.net.HttpRetryException: Cannot retry