java - Unable to read entire POST request body content formatted as application/json -
i've been having issue jetty processing application/json formatted request body data. essentially, when request body processed jetty, request data cut off.
i have relatively large post body of around 74,000 bytes. per advice found online, instantiated new context handler setmaxformcontentsize property set sufficiently large size of 500,000 bytes.
servletcontexthandler handler = new servletcontexthandler(server, "/"); handler.setmaxformcontentsize(500000); however, did not seem work correctly. read online property might work form encoded data, not application/json, strict requirement of our application.
is there way circumvent issue? there special constraint class can subclass allow processing size increase @ least 500kb?
edit #1: should add tried drop size of limit 5 bytes see if cut off more of data in payload. didn't working, seems imply that's ignoring property entirely.
edit #2: here read information request stream.
@override protected void dopost(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { try { string json = charstreams.tostring(new inputstreamreader(req.getinputstream())); .... } catch (exception e) { logger.error("exception in internal api forwarder", e); throw e; } } this seems standard way of reading request stream. tried using bufferedreader req.getreader() same issue.
vivek
what charstreams object?
it doesn't seem know, or care, or honor request character encoding. (bad idea)
suggest use servlet request.getreader() instead of request.getinputstream() (which designed binary request body content)
using request.getreader() @ least support request character encoding properly.
another bit of information might want request.getcontentlength() , verify request headers indeed contain size expecting.
Comments
Post a Comment