MCPcopy Create free account
hub / github.com/apache/tomcat / doParseParameters

Method doParseParameters

java/org/apache/catalina/connector/Request.java:2977–3113  ·  view source on GitHub ↗

Parse request parameters.

()

Source from the content-addressed store, hash-verified

2975 * Parse request parameters.
2976 */
2977 protected void doParseParameters() {
2978 if (parametersParsed) {
2979 return;
2980 }
2981 parametersParsed = true;
2982
2983 /*
2984 * When the request body is multipart/form-data, both the parts and the query string count towards
2985 * maxParameterCount. If parseParts() is called before getParameterXXX() then the parts will be parsed before
2986 * the query string. Otherwise, the query string will be parsed first.
2987 *
2988 * maxParameterCount must be respected regardless of which is parsed first.
2989 *
2990 * maxParameterCount is reset from the Connector at the start of every request.
2991 *
2992 * If parts are parsed first, non-file parts will be added to the parameter map and any files will reduce
2993 * maxParameterCount by 1 so that when the query string is parsed the difference between the size of the
2994 * parameter map and maxParameterCount will be the original maxParameterCount less the number of parts. i.e. the
2995 * maxParameterCount applied to the query string will be the original maxParameterCount less the number of
2996 * parts.
2997 *
2998 * If the query string is parsed first, all parameters will be added to the parameter map and, ignoring
2999 * maxPartCount, the part limit will be set to the original maxParameterCount less the size of the parameter
3000 * map. i.e. the maxParameterCount applied to the parts will be the original maxParameterCount less the number
3001 * of query parameters.
3002 */
3003 Parameters parameters = coyoteRequest.getParameters();
3004 parameters.setLimit(maxParameterCount);
3005
3006 // getCharacterEncoding() may have been overridden to search for
3007 // hidden form field containing request encoding
3008 Charset charset = getCharset();
3009
3010 boolean useBodyEncodingForURI = connector.getUseBodyEncodingForURI();
3011 parameters.setCharset(charset);
3012 if (useBodyEncodingForURI) {
3013 parameters.setQueryStringCharset(charset);
3014 }
3015 // Note: If !useBodyEncodingForURI, the query string encoding is
3016 // that set towards the start of CoyoteAdapter.service()
3017
3018 parameters.handleQueryParameters();
3019
3020 if (usingInputStream || usingReader) {
3021 return;
3022 }
3023
3024 String mediaType = MediaType.parseMediaTypeOnly(getContentType());
3025
3026 if ("multipart/form-data".equals(mediaType)) {
3027 parseParts(false);
3028 if (partsParseException instanceof IllegalStateException) {
3029 parametersParseException = (IllegalStateException) partsParseException;
3030 } else if (partsParseException != null) {
3031 parametersParseException = new InvalidParameterException(partsParseException);
3032 }
3033 return;
3034 }

Callers 1

parseParametersMethod · 0.95

Calls 15

setLimitMethod · 0.95
getCharsetMethod · 0.95
setCharsetMethod · 0.95
setQueryStringCharsetMethod · 0.95
handleQueryParametersMethod · 0.95
parseMediaTypeOnlyMethod · 0.95
getContentTypeMethod · 0.95
parsePartsMethod · 0.95
getConnectorMethod · 0.95
getMethodMethod · 0.95
getContentLengthMethod · 0.95
getContextMethod · 0.95

Tested by

no test coverage detected