Package org.springframework.http

Examples of org.springframework.http.HttpOutputMessage


        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


    Class<?> partType = partBody.getClass();
    HttpHeaders partHeaders = partEntity.getHeaders();
    MediaType partContentType = partHeaders.getContentType();
    for (HttpMessageConverter messageConverter : partConverters) {
      if (messageConverter.canWrite(partType, partContentType)) {
        HttpOutputMessage multipartOutputMessage = new MultipartHttpOutputMessage(os);
        multipartOutputMessage.getHeaders().setContentDispositionFormData(name, getFilename(partBody));
        if (!partHeaders.isEmpty()) {
          multipartOutputMessage.getHeaders().putAll(partHeaders);
        }
        messageConverter.write(partBody, partContentType, multipartOutputMessage);
        return;
      }
    }
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

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

        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();
      if (!entityHeaders.isEmpty()) {
        outputMessage.getHeaders().putAll(entityHeaders);
      }
      Object body = responseEntity.getBody();
      if (body != null) {
        writeWithMessageConverters(body, inputMessage, outputMessage);
      }
      else {
        // flush headers
        outputMessage.getBody();
      }
    }
View Full Code Here

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

        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();
      if (!entityHeaders.isEmpty()) {
        outputMessage.getHeaders().putAll(entityHeaders);
      }
      Object body = responseEntity.getBody();
      if (body != null) {
        writeWithMessageConverters(body, inputMessage, outputMessage);
      }
      else {
        // flush headers
        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

    @Test
    public void shouldWrite() throws Exception {
        UploadApplicationPayload payload = mock(UploadApplicationPayload.class);
        given(payload.getInputStream()).willReturn(new ByteArrayInputStream(CONTENT));
        HttpOutputMessage outputMessage = mock(HttpOutputMessage.class);
        HttpHeaders headers = mock(HttpHeaders.class);
        given(outputMessage.getHeaders()).willReturn(headers);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        given(outputMessage.getBody()).willReturn(out);
        converter.write(payload, null, outputMessage);
        verify(headers).setContentType(MediaType.APPLICATION_OCTET_STREAM);
        assertThat(out.toByteArray(), is(equalTo(CONTENT)));
    }
View Full Code Here

  public 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();
    if (!entityHeaders.isEmpty()) {
      outputMessage.getHeaders().putAll(entityHeaders);
    }
    Object body = responseEntity.getBody();
    if (body != null) {
      writeWithMessageConverters(body, inputMessage, outputMessage);
    }
    else {
      // flush headers
      outputMessage.getBody();
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.HttpOutputMessage

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.