protectedvoidparseParameters() { //标识位,标志已经被解析过。 parametersParsed = true; Parametersparameters= coyoteRequest.getParameters(); booleansuccess=false; try { // Set this every time in case limit has been changed via JMX parameters.setLimit(getConnector().getMaxParameterCount());
// getCharacterEncoding() may have been overridden to search for // hidden form field containing request encoding Stringenc= getCharacterEncoding();
booleanuseBodyEncodingForURI= connector.getUseBodyEncodingForURI(); if (enc != null) { parameters.setEncoding(enc); if (useBodyEncodingForURI) { parameters.setQueryStringEncoding(enc); } } else { parameters.setEncoding (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING); if (useBodyEncodingForURI) { parameters.setQueryStringEncoding (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING); } }
/** * Create a new ContentCachingResponseWrapper for the given servlet response. * @param response the original servlet response */ publicContentCachingResponseWrapper(HttpServletResponse response) { super(response); }
@Override publicvoidsendError(int sc)throws IOException { copyBodyToResponse(false); try { super.sendError(sc); } catch (IllegalStateException ex) { // Possibly on Tomcat when called too late: fall back to silent setStatus super.setStatus(sc); } this.statusCode = sc; }
@Override @SuppressWarnings("deprecation") publicvoidsendError(int sc, String msg)throws IOException { copyBodyToResponse(false); try { super.sendError(sc, msg); } catch (IllegalStateException ex) { // Possibly on Tomcat when called too late: fall back to silent setStatus super.setStatus(sc, msg); } this.statusCode = sc; }
/** * Return the status code as specified on the response. */ publicintgetStatusCode() { returnthis.statusCode; }
/** * Return the cached response content as a byte array. */ publicbyte[] getContentAsByteArray() { returnthis.content.toByteArray(); }
/** * Return an {@link InputStream} to the cached content. * @since 4.2 */ public InputStream getContentInputStream() { returnthis.content.getInputStream(); }
/** * Return the current size of the cached content. * @since 4.2 */ publicintgetContentSize() { returnthis.content.size(); }
/** * Copy the complete cached body content to the response. * @since 4.2 */ publicvoidcopyBodyToResponse()throws IOException { copyBodyToResponse(true); }
/** * Copy the cached body content to the response. * @param complete whether to set a corresponding content length * for the complete cached body content * @since 4.2 */ protectedvoidcopyBodyToResponse(boolean complete)throws IOException { if (this.content.size() > 0) { HttpServletResponserawResponse= (HttpServletResponse) getResponse(); if ((complete || this.contentLength != null) && !rawResponse.isCommitted()) { rawResponse.setContentLength(complete ? this.content.size() : this.contentLength); this.contentLength = null; } this.content.writeTo(rawResponse.getOutputStream()); this.content.reset(); if (complete) { super.flushBuffer(); } } }