Package org.springframework.http.server

Examples of org.springframework.http.server.ServletServerHttpResponse


        acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
      }
     
      MediaType.sortByQualityValue(acceptedMediaTypes);
     
      HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
     
      for (MediaType acceptedMediaType : acceptedMediaTypes) {
        for (HttpMessageConverter messageConverter : messageConverters) {
          if (messageConverter.canWrite(error.getClass(), acceptedMediaType)) {
            messageConverter.write(error, acceptedMediaType, outputMessage);
View Full Code Here


    if (returnValue == null) {
      return;
    }

    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);

    Assert.isInstanceOf(HttpEntity.class, returnValue);
    HttpEntity<?> responseEntity = (HttpEntity<?>) returnValue;
    if (responseEntity instanceof ResponseEntity) {
      outputMessage.setStatusCode(((ResponseEntity<?>) responseEntity).getStatusCode());
    }

    HttpHeaders entityHeaders = responseEntity.getHeaders();
    if (!entityHeaders.isEmpty()) {
      outputMessage.getHeaders().putAll(entityHeaders);
    }

    Object body = responseEntity.getBody();
    if (body != null) {
      writeWithMessageConverters(body, returnType, inputMessage, outputMessage);
    }
    else {
      // flush headers to the HttpServletResponse
      outputMessage.getBody();
    }
  }
View Full Code Here

   * @param webRequest the web request to create an output message from
   * @return the output message
   */
  protected ServletServerHttpResponse createOutputMessage(NativeWebRequest webRequest) {
    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    return new ServletServerHttpResponse(response);
  }
View Full Code Here

  protected <T> void writeWithMessageConverters(T returnValue,
                          MethodParameter returnType,
                          NativeWebRequest webRequest)
      throws IOException, HttpMediaTypeNotAcceptableException {
    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
    writeWithMessageConverters(returnValue, returnType, inputMessage, outputMessage);
  }
View Full Code Here

    if (returnValue == null) {
      return;
    }

    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);

    Assert.isInstanceOf(HttpEntity.class, returnValue);
    HttpEntity<?> responseEntity = (HttpEntity<?>) returnValue;
    if (responseEntity instanceof ResponseEntity) {
      outputMessage.setStatusCode(((ResponseEntity<?>) responseEntity).getStatusCode());
    }

    HttpHeaders entityHeaders = responseEntity.getHeaders();
    if (!entityHeaders.isEmpty()) {
      outputMessage.getHeaders().putAll(entityHeaders);
    }
   
    Object body = responseEntity.getBody();
    if (body != null) {
      writeWithMessageConverters(body, returnType, inputMessage, outputMessage);
    }
    else {
      // flush headers to the HttpServletResponse
      outputMessage.getBody();
    }
  }
View Full Code Here

    List<MediaType> acceptedMediaTypes = inputMessage.getHeaders().getAccept();
    if (acceptedMediaTypes.isEmpty()) {
      acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
    }
    MediaType.sortByQualityValue(acceptedMediaTypes);
    HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
    Class<?> returnValueType = returnValue.getClass();
    if (this.messageConverters != null) {
      for (MediaType acceptedMediaType : acceptedMediaTypes) {
        for (HttpMessageConverter messageConverter : this.messageConverters) {
          if (messageConverter.canWrite(returnValueType, acceptedMediaType)) {
View Full Code Here

   * @param webRequest the web request to create an output message from
   * @return the output message
   */
  protected ServletServerHttpResponse createOutputMessage(NativeWebRequest webRequest) {
    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    return new ServletServerHttpResponse(response);
  }
View Full Code Here

  protected <T> void writeWithMessageConverters(T returnValue,
                          MethodParameter returnType,
                          NativeWebRequest webRequest)
      throws IOException, HttpMediaTypeNotAcceptableException {
    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
    writeWithMessageConverters(returnValue, returnType, inputMessage, outputMessage);
  }
View Full Code Here

   * @param servletResponse current HTTP response
   * @return the HttpInputMessage instance to use
   * @throws Exception in case of errors
   */
    protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletResponse) throws Exception {
    return new ServletServerHttpResponse(servletResponse);
  }
View Full Code Here

   * @param servletResponse current HTTP response
   * @return the HttpInputMessage instance to use
   * @throws Exception in case of errors
   */
    protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletResponse) throws Exception {
    return new ServletServerHttpResponse(servletResponse);
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.server.ServletServerHttpResponse

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.