android - Apache 2.4.6 - Sending GZIP content SOMETIMES results in "read more bytes of request body than expected" -


we trying send gziped content web application hosted on tomcat behind apache 2 via mod_proxy's proxypass , proxypassreverse directives. of time works apache rejects these packages , following errors in our apache error logs:

[proxy_http:error] ... ah01086: read more bytes of request body expected (got 16384, expected 1562)   [proxy_http:error] ... ah01097: pass request body failed x.x.x.x:8080 (x.x.x.x) x (x.x.x.x) 

the code sending data based on httpsurlconnection , executed android device. looks this:

url url = new url(constants.url); httpsurlconnection con = (httpsurlconnection) url.openconnection();  con.setrequestmethod("post"); con.setusecaches(false); con.setdoinput(true); con.setdooutput(true); con.setrequestproperty("content-encoding", "gzip"); con.setrequestproperty("content-type", "application/json"); con.setrequestproperty("accept", "application/json"); con.setrequestproperty("user-agent", "myapp 1.0");  outputstream outputstream = con.getoutputstream(); outputstream.write( zipstringtobytes("some possibly long content.") );  outputstream.flush(); outputstream.close();  int responsecode = con.getresponsecode(); 

and function create our gzip string:

private static byte[] zipstringtobytes(string input) throws ioexception {     bytearrayoutputstream bos = new bytearrayoutputstream();      //use printstream avod converting string byte array, can cause out of memory error     final printstream printstream = new printstream(new gzipoutputstream(bos));     printstream.print(input);     printstream.close();      byte[] retval = bos.tobytearray();     bos.close();     return retval; } 

we have not been able figure out reason yet. since seems occur sporadically. makes think might problem content-length, or our code sending data in general, don't know , cannot find , related issues. if have pointers on this, appreciate it.

if need more information, please let me know.

update: found is, expected size same: 16384 expected size varies. maybe helps.

update 2: have disabled chunked mode: con.setchunkedstreamingmode ( 0 ) seems help. can maybe explain if solution , why one. thanks.

ok, able solve issue disabling sending data in chunked mode.

con.setchunkedstreamingmode ( 0 ) 

while have ideas why solves issue, have not come in depth explanation.

as long nobody has better solution or explanation, accept solution.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -