@Override public ParameterValue getParameter(String name) { return request.getParameter(name); }
public String getContentType() { if (contentType == null) { String httpServletRequestContentType = httpServletRequest.getHeader(HttpConstants.Header.CONTENT_TYPE); if (HttpConstants.Method.POST.equals(httpServletRequest.getMethod()) && (HttpConstants.ContentType.APPLICATION_FORM_URLENCODED.equals(httpServletRequestContentType) || HttpConstants.ContentType.MULTIPART_FORM_DATA.equals(httpServletRequestContentType))) { // Allow forms to exercise RESTful API endpoints by POSTing content like 'application/json'. // This parameter is usually paired with '_method' and '_content' parameters. contentType = getParameter("_content_type").toString(httpServletRequestContentType); } else { contentType = httpServletRequestContentType; } } return contentType; }
public String getMethod() { if (method == null) { String httpServletRequestMethod = httpServletRequest.getMethod(); String httpServletRequestContentType = httpServletRequest.getHeader(HttpConstants.Header.CONTENT_TYPE); if (HttpConstants.Method.POST.equals(httpServletRequestMethod) && (HttpConstants.ContentType.APPLICATION_FORM_URLENCODED.equals(httpServletRequestContentType) || HttpConstants.ContentType.MULTIPART_FORM_DATA.equals(httpServletRequestContentType))) { // Allow forms to more discretely control the Pippo form handler and encourages RESTful design. // This parameter may be paired with the '_content_type' and '_content' parameters. method = getParameter("_method").toString(httpServletRequestMethod).toUpperCase(); } else { method = httpServletRequestMethod; } } return method; }
public String getBody() { if (body == null) { String httpServletRequestContentType = httpServletRequest.getHeader(HttpConstants.Header.CONTENT_TYPE); if (HttpConstants.Method.POST.equals(httpServletRequest.getMethod()) && (HttpConstants.ContentType.APPLICATION_FORM_URLENCODED.equals(httpServletRequestContentType) || HttpConstants.ContentType.MULTIPART_FORM_DATA.equals(httpServletRequestContentType))) { // Allow forms to exercise RESTful API endpoints by POSTing content like 'application/json'. // This parameter is usually paired with '_method' and '_content_type' parameters. body = getParameter("_content").toString(null); } else { try { body = IoUtils.toString(httpServletRequest.getInputStream()); } catch (Exception e) { throw new PippoRuntimeException(e, "Exception when reading the request body"); } } } return body; }
@Override public String getRequestParameter(String name) { ParameterValue parameter = getRequest().getParameter(name); return parameter.isNull() ? null : parameter.toString(); }