Java Code Examples for javax.servlet.http.HttpServletResponse#SC_REQUEST_ENTITY_TOO_LARGE
The following examples show how to use
javax.servlet.http.HttpServletResponse#SC_REQUEST_ENTITY_TOO_LARGE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Perform whatever actions are required to flush and close the input * stream or reader, in a single operation. * * @exception IOException if an input/output error occurs */ public void finishRequest() throws IOException { // Optionally disable swallowing of additional request data. Context context = getContext(); if (context != null && response.getStatus() == HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE && !context.getSwallowAbortedUploads()) { coyoteRequest.action(ActionCode.DISABLE_SWALLOW_INPUT, null); } }
Example 2
Source File: Request.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Perform whatever actions are required to flush and close the input * stream or reader, in a single operation. * * @exception IOException if an input/output error occurs */ public void finishRequest() throws IOException { // Optionally disable swallowing of additional request data. Context context = getContext(); if (context != null && response.getStatus() == HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE && !context.getSwallowAbortedUploads()) { coyoteRequest.action(ActionCode.DISABLE_SWALLOW_INPUT, null); } }
Example 3
Source File: ServletInputStreamImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public String readLine() throws IOException, HttpException { if (lineBuffer == null) { lineBuffer = new byte[127]; } int count = readLine(lineBuffer, 0, lineBuffer.length); int offset = count; while (count > 0 && offset == lineBuffer.length && lineBuffer[offset - 1] != '\n') { // double the size of the buffer final int newsize = offset * 2 + 1; if (newsize > limitRequestLine) { throw new HttpException( HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE, "Request line length exceeds upper limit"); } byte[] tmp = new byte[newsize]; System.arraycopy(lineBuffer, 0, tmp, 0, offset); lineBuffer = tmp; tmp = null; count = readLine(lineBuffer, offset, lineBuffer.length - offset); offset += count; } if (count == -1) { throw new IOException("End of stream reached before CRLF"); } return HttpUtil.newString(lineBuffer, 0, 0, offset - 2); // remove // CRLF }
Example 4
Source File: FailedRequestFilter.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!isGoodRequest(request)) { FailReason reason = (FailReason) request.getAttribute( Globals.PARAMETER_PARSE_FAILED_REASON_ATTR); int status; switch (reason) { case IO_ERROR: // Not the client's fault status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; break; case POST_TOO_LARGE: status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE; break; case TOO_MANY_PARAMETERS: // 413/414 aren't really correct here since the request body // and/or URI could be well below any limits set. Use the // default. case UNKNOWN: // Assume the client is at fault // Various things that the client can get wrong that don't have // a specific status code so use the default. case INVALID_CONTENT_TYPE: case MULTIPART_CONFIG_INVALID: case NO_NAME: case REQUEST_BODY_INCOMPLETE: case URL_DECODING: case CLIENT_DISCONNECT: // Client is never going to see this so this is really just // for the access logs. The default is fine. default: // 400 status = HttpServletResponse.SC_BAD_REQUEST; break; } ((HttpServletResponse) response).sendError(status); return; } chain.doFilter(request, response); }
Example 5
Source File: FailedRequestFilter.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!isGoodRequest(request)) { FailReason reason = (FailReason) request.getAttribute( Globals.PARAMETER_PARSE_FAILED_REASON_ATTR); int status; switch (reason) { case IO_ERROR: // Not the client's fault status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; break; case POST_TOO_LARGE: status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE; break; case TOO_MANY_PARAMETERS: // 413/414 aren't really correct here since the request body // and/or URI could be well below any limits set. Use the // default. case UNKNOWN: // Assume the client is at fault // Various things that the client can get wrong that don't have // a specific status code so use the default. case INVALID_CONTENT_TYPE: case MULTIPART_CONFIG_INVALID: case NO_NAME: case REQUEST_BODY_INCOMPLETE: case URL_DECODING: case CLIENT_DISCONNECT: // Client is never going to see this so this is really just // for the access logs. The default is fine. default: // 400 status = HttpServletResponse.SC_BAD_REQUEST; break; } ((HttpServletResponse) response).sendError(status); return; } chain.doFilter(request, response); }
Example 6
Source File: MaxUploadLengthExceededException.java From tus-java-server with MIT License | 4 votes |
public MaxUploadLengthExceededException(String message) { super(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE, message); }
Example 7
Source File: FailedRequestFilter.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!isGoodRequest(request)) { FailReason reason = (FailReason) request.getAttribute( Globals.PARAMETER_PARSE_FAILED_REASON_ATTR); int status; switch (reason) { case IO_ERROR: // Not the client's fault status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; break; case POST_TOO_LARGE: status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE; break; case TOO_MANY_PARAMETERS: // 413/414 aren't really correct here since the request body // and/or URI could be well below any limits set. Use the // default. case UNKNOWN: // Assume the client is at fault // Various things that the client can get wrong that don't have // a specific status code so use the default. case INVALID_CONTENT_TYPE: case MULTIPART_CONFIG_INVALID: case NO_NAME: case REQUEST_BODY_INCOMPLETE: case URL_DECODING: case CLIENT_DISCONNECT: // Client is never going to see this so this is really just // for the access logs. The default is fine. default: // 400 status = HttpServletResponse.SC_BAD_REQUEST; break; } ((HttpServletResponse) response).sendError(status); return; } chain.doFilter(request, response); }
Example 8
Source File: HeaderBase.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
void parseHeaders(ServletInputStreamImpl in) throws HttpException, IOException { String name = null; String value = null; ArrayList<String> values = null; final int limit = httpConfig.getLimitRequestHeaders() - 1; String line = in.readLine(); while (line != null && line.length() > 0) { // Activator.log.info(Thread.currentThread().getName() + " - Attempting to parse: " + line); if (headers.size() > limit) { throw new HttpException(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE); } final char c = line.charAt(0); if (c == ' ' || c == '\t') { // continued header value // check not first line if (!(name != null && value != null && values != null)) { throw new HttpException(HttpServletResponse.SC_BAD_REQUEST); } // set concatenated header value value = value + line.substring(1); values.remove(values.size() - 1); values.add(value); } else { final int index = line.indexOf(": "); // get header name name = line.substring(0, index).trim().toLowerCase(); // get header value @SuppressWarnings("unchecked") final ArrayList<String> newValues = (ArrayList<String>) headers.get(name); values = newValues; if (values == null) { values = new ArrayList<String>(); } // add header value to vector value = line.substring(index + 2); values.add(value); headers.put(name, values); } // read next line line = in.readLine(); } }
Example 9
Source File: Request.java From Tomcat8-Source-Read with MIT License | 2 votes |
/** * Perform whatever actions are required to flush and close the input * stream or reader, in a single operation. * * @exception IOException if an input/output error occurs */ public void finishRequest() throws IOException { if (response.getStatus() == HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE) { checkSwallowInput(); } }