How do I explicitly disable chunked streaming mode for HTTP connections in Android?

雨燕双飞 提交于 2019-11-30 12:00:39

Bummer! The solution is to not call setChunkedStreamingMode() (or even setFixedStreamingMode()) from the client code at all! "-1" are the internal default values for fixedLength and chunkedLength and cannot be set client-side, because setting a value lower or equal to "0" lets it default to HttpEngine.DEFAULT_CHUNK_LENGTH (or throws an exception in the fixed streaming mode case).

Christopher Schultz

The solution is to set a Content-Length header (which may be set by this next part) and call setFixedLengthStreamingMode with the proper length of the POST message you intend to send.

See the "streaming mode" section in this SO FAQ:

Using java.net.URLConnection to fire and handle HTTP requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!