Package org.springframework.http

Examples of org.springframework.http.HttpInputMessage


  @Override
  protected void doFilterInternal(final HttpServletRequest request, HttpServletResponse response,
      FilterChain filterChain) throws ServletException, IOException {

    if (("PUT".equals(request.getMethod()) || "PATCH".equals(request.getMethod())) && isFormContentType(request)) {
      HttpInputMessage inputMessage = new ServletServerHttpRequest(request) {
        @Override
        public InputStream getBody() throws IOException {
          return request.getInputStream();
        }
      };
View Full Code Here


  @Override
  protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
      MethodParameter methodParam,  Type paramType) throws IOException, HttpMediaTypeNotSupportedException {

    final HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    HttpInputMessage inputMessage = new ServletServerHttpRequest(servletRequest);

    InputStream inputStream = inputMessage.getBody();
    if (inputStream == null) {
      return handleEmptyBody(methodParam);
    }
    else if (inputStream.markSupported()) {
      inputStream.mark(1);
View Full Code Here

   * @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
   */
  protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
      MethodParameter methodParam, Type paramType) throws IOException, HttpMediaTypeNotSupportedException {

    HttpInputMessage inputMessage = createInputMessage(webRequest);
    return readWithMessageConverters(inputMessage, methodParam, paramType);
  }
View Full Code Here

  }

  private HttpEntity<?> resolveHttpEntityRequest(MethodParameter methodParam, NativeWebRequest webRequest)
      throws Exception {

    HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
    Class<?> paramType = getHttpEntityType(methodParam);
    Object body = readWithMessageConverters(methodParam, inputMessage, paramType);
    return new HttpEntity<Object>(body, inputMessage.getHeaders());
  }
View Full Code Here

    private void handleResponseBody(Object returnValue, ServletWebRequest webRequest)
        throws Exception {
      if (returnValue == null) {
        return;
      }
      HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
      HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
      writeWithMessageConverters(returnValue, inputMessage, outputMessage);
    }
View Full Code Here

    private void handleHttpEntityResponse(HttpEntity<?> responseEntity, ServletWebRequest webRequest)
        throws Exception {
      if (responseEntity == null) {
        return;
      }
      HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
      HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
      if (responseEntity instanceof ResponseEntity && outputMessage instanceof ServerHttpResponse) {
        ((ServerHttpResponse) outputMessage).setStatusCode(((ResponseEntity<?>) responseEntity).getStatusCode());
      }
      HttpHeaders entityHeaders = responseEntity.getHeaders();
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes", "resource" })
  private ModelAndView handleResponseBody(Object returnValue, ServletWebRequest webRequest)
      throws ServletException, IOException {

    HttpInputMessage inputMessage = new ServletServerHttpRequest(webRequest.getRequest());
    List<MediaType> acceptedMediaTypes = inputMessage.getHeaders().getAccept();
    if (acceptedMediaTypes.isEmpty()) {
      acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
    }
    MediaType.sortByQualityValue(acceptedMediaTypes);
    HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
View Full Code Here

      assertIsMultipartRequest(servletRequest);
      arg = RequestPartResolver.resolvePart(servletRequest);
    }
    else {
      try {
        HttpInputMessage inputMessage = new RequestPartServletServerHttpRequest(servletRequest, partName);
        arg = readWithMessageConverters(inputMessage, parameter, parameter.getParameterType());
        WebDataBinder binder = binderFactory.createBinder(request, arg, partName);
        if (arg != null) {
          validate(binder, parameter);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    private void handleResponseBody(Object returnValue, ServletWebRequest webRequest)
        throws ServletException, IOException {

      HttpInputMessage inputMessage = new ServletServerHttpRequest(webRequest.getRequest());
      List<MediaType> acceptedMediaTypes = inputMessage.getHeaders().getAccept();
      if (acceptedMediaTypes.isEmpty()) {
        acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
      }
      MediaType.sortBySpecificity(acceptedMediaTypes);
      HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected Object resolveRequestBody(MethodParameter methodParam, NativeWebRequest webRequest, Object handler)
      throws Exception {

    HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
    Class paramType = methodParam.getParameterType();
    MediaType contentType = inputMessage.getHeaders().getContentType();
    if (contentType == null) {
      StringBuilder builder = new StringBuilder(ClassUtils.getShortName(methodParam.getParameterType()));
      String paramName = methodParam.getParameterName();
      if (paramName != null) {
        builder.append(' ');
View Full Code Here

TOP

Related Classes of org.springframework.http.HttpInputMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.