Refine search
private static boolean isFormPost(HttpServletRequest request) { String contentType = request.getContentType(); return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) && HttpMethod.POST.matches(request.getMethod())); }
private boolean shouldParse(HttpServletRequest request) { if (!HTTP_METHODS.contains(request.getMethod())) { return false; } try { MediaType mediaType = MediaType.parseMediaType(request.getContentType()); return MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType); } catch (IllegalArgumentException ex) { return false; } }
private boolean shouldSetCharacterEncoding(HttpServletRequest req) { String method = req.getMethod(); if (!"POST".equalsIgnoreCase(method)) { return false; } // containers often implement RFCs incorrectly in that it doesn't interpret query parameter // decoding with UTF-8. This will ensure we get it right. // but doing this for config.xml submission could potentially overwrite valid // "text/xml;charset=xxx" String contentType = req.getContentType(); if (contentType != null) { boolean isXmlSubmission = contentType.startsWith("application/xml") || contentType.startsWith("text/xml"); if (isXmlSubmission) { return false; } } if (FORCE_ENCODING || req.getCharacterEncoding() == null) { return true; } return false; }
private static boolean isFormPost(HttpServletRequest request) { String contentType = request.getContentType(); return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) && HttpMethod.POST.matches(request.getMethod())); }
private boolean shouldParse(HttpServletRequest request) { if (!HTTP_METHODS.contains(request.getMethod())) { return false; } try { MediaType mediaType = MediaType.parseMediaType(request.getContentType()); return MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType); } catch (IllegalArgumentException ex) { return false; } }
requestType = CORSRequestType.INVALID_CORS; } else { String method = request.getMethod(); if (method != null && HTTP_METHODS.contains(method)) { if ("OPTIONS".equals(method)) { requestType = CORSRequestType.SIMPLE; } else if ("POST".equals(method)) { String contentType = request.getContentType(); if (contentType != null) { contentType = contentType.toLowerCase().trim();
protected void parseParameters() { if (myParameterMap != null) return; String contentType = myWrappedRequest.getContentType(); if (myWrappedRequest.getMethod().equals("POST") && contentType != null && contentType.startsWith("application/x-www-form-urlencoded")) { parseFormBody(); } else { myParameterMap = new HashMap(super.getParameterMap()); for (Object key : myParameterMap.keySet()) { Object value = myParameterMap.get(key); if (value instanceof String[]) { myParameterMap.put(key, Arrays.asList(((String[]) value))); } else if (!(value instanceof List)) { myParameterMap.put(key, Converters.convert(value, List.class)); } } } }
public static HttpServletRequest getRequestWithUpstream(final String clientIp, final String upstreamIp, final String sessionId, final String requestMethod) { final HttpServletRequest req = mock(HttpServletRequest.class); when(req.getRemoteAddr()).thenReturn("2.2.2.2:9999"); when(req.getHeader("x-forwarded-for")).thenReturn(upstreamIp); when(req.getMethod()).thenReturn(requestMethod); when(req.getContentType()).thenReturn("application/x-www-form-urlencoded"); // Requires sessionId to be passed that is in the application's session cache when(req.getParameter("session.id")).thenReturn(sessionId); return req; }
public static HttpServletRequest getRequestWithNoUpstream(final String clientIp, final String sessionId, final String requestMethod) { final HttpServletRequest req = mock(HttpServletRequest.class); when(req.getRemoteAddr()).thenReturn(clientIp); when(req.getHeader("x-forwarded-for")).thenReturn(null); when(req.getMethod()).thenReturn(requestMethod); when(req.getContentType()).thenReturn("application/x-www-form-urlencoded"); // Requires sessionId to be passed that is in the application's session cache when(req.getParameter("session.id")).thenReturn(sessionId); return req; }
public static HttpServletRequest getRequestWithMultipleUpstreams(final String clientIp, final String upstreamIp, final String sessionId, final String requestMethod) { final HttpServletRequest req = mock(HttpServletRequest.class); when(req.getRemoteAddr()).thenReturn("2.2.2.2:9999"); when(req.getHeader("x-forwarded-for")).thenReturn(upstreamIp + ",1.1.1.1,3.3.3.3:33333"); when(req.getMethod()).thenReturn(requestMethod); when(req.getContentType()).thenReturn("application/x-www-form-urlencoded"); // Requires sessionId to be passed that is in the application's session cache when(req.getParameter("session.id")).thenReturn(sessionId); return req; }
if ("POST".equals(req.getMethod())) { String contentType = req.getContentType(); if (contentType != null) { if (uc != null && contentType.contains("multipart/form-data")) {
log.debug("Request - method: {} content type: {} path: {}", new Object[] { req.getMethod(), req.getContentType(), req.getServletPath() }); if (!REQUEST_METHOD.equals(req.getMethod()) || req.getContentLength() == 0) { if (enforceContentTypeCheck && !CONTENT_TYPE.equals(req.getContentType())) { handleBadRequest(String.format("Bad request, unsupported content type: %s.", req.getContentType()), resp); return;
if (HttpMethod.OPTIONS.matches(request.getMethod())) { HttpOptionsHandler handler = new HttpOptionsHandler(methods); return new HandlerMethod(handler, HTTP_OPTIONS_HANDLE_METHOD); throw new HttpRequestMethodNotSupportedException(request.getMethod(), methods); Set<MediaType> mediaTypes = helper.getConsumableMediaTypes(); MediaType contentType = null; if (StringUtils.hasLength(request.getContentType())) { try { contentType = MediaType.parseMediaType(request.getContentType());
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()) || APPLICATION_SMILE.equals(request.getContentType()); final ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper; request.setAttribute(OBJECTMAPPER_ATTRIBUTE, objectMapper); final String method = request.getMethod(); final Server targetServer;
try { putAttribute(attributes, HTTPUtils.HTTP_CONTEXT_ID, contextIdentifier); putAttribute(attributes, "mime.type", request.getContentType()); putAttribute(attributes, "http.servlet.path", request.getServletPath()); putAttribute(attributes, "http.context.path", request.getContextPath()); putAttribute(attributes, "http.method", request.getMethod()); putAttribute(attributes, "http.local.addr", request.getLocalAddr()); putAttribute(attributes, HTTPUtils.HTTP_LOCAL_NAME, request.getLocalName());
Request init(Request request) throws ServiceException, IOException { HttpServletRequest httpRequest = request.getHttpRequest(); String reqContentType = httpRequest.getContentType(); request.setGet("GET".equalsIgnoreCase(httpRequest.getMethod()) || isForm(reqContentType)); if (httpRequest.getContentType() != null && httpRequest.getContentType().startsWith(SOAP_MIME)) { request.setSOAP(true); request.setInput(soapReader(httpRequest, request));
final String contentType = request.getContentType(); if (contentType == null) { if (!"POST".equalsIgnoreCase(request.getMethod())) {
String[] pathArgs) { try { if (!"POST".equals(request.getMethod()) && !"PUT".equals(request.getMethod())) { String str = "Not POST or PUT, Wrong HTTP method! --> " + request.getMethod(); throw new UploadException(str); String contentType = request.getContentType(); if (contentType == null) { throw new UploadException("Content-Type is NULL!!");
if (HttpMethod.OPTIONS.matches(request.getMethod())) { HttpOptionsHandler handler = new HttpOptionsHandler(methods); return new HandlerMethod(handler, HTTP_OPTIONS_HANDLE_METHOD); throw new HttpRequestMethodNotSupportedException(request.getMethod(), methods); Set<MediaType> mediaTypes = helper.getConsumableMediaTypes(); MediaType contentType = null; if (StringUtils.hasLength(request.getContentType())) { try { contentType = MediaType.parseMediaType(request.getContentType());
EasyMock.expect(requestMock.getContentType()).andReturn("application/json").times(2); requestMock.setAttribute("org.apache.druid.proxy.objectMapper", jsonMapper); EasyMock.expectLastCall(); EasyMock.expect(requestMock.getRequestURI()).andReturn("/druid/v2/"); EasyMock.expect(requestMock.getMethod()).andReturn("POST"); EasyMock.expect(requestMock.getInputStream()).andReturn(servletInputStream); requestMock.setAttribute("org.apache.druid.proxy.query", query);