Package org.springframework.http

Examples of org.springframework.http.StreamingHttpOutputMessage


        headers.setContentLength(contentLength);
      }
    }

    if (outputMessage instanceof StreamingHttpOutputMessage) {
      StreamingHttpOutputMessage streamingOutputMessage =
          (StreamingHttpOutputMessage) outputMessage;
      streamingOutputMessage.setBody(new StreamingHttpOutputMessage.Body() {
        @Override
        public void writeTo(final OutputStream outputStream) throws IOException {
          writeInternal(t, new HttpOutputMessage() {
            @Override
            public OutputStream getBody() throws IOException {
View Full Code Here


    request.getHeaders().add(headerName, headerValue2);
    final byte[] body = "Hello World".getBytes("UTF-8");
    request.getHeaders().setContentLength(body.length);

    if (request instanceof StreamingHttpOutputMessage) {
      StreamingHttpOutputMessage streamingRequest = (StreamingHttpOutputMessage) request;
      streamingRequest.setBody(outputStream -> StreamUtils.copy(body, outputStream));
    }
    else {
      StreamUtils.copy(body, request.getBody());
    }
View Full Code Here

  public void multipleWrites() throws Exception {
    AsyncClientHttpRequest request = this.factory.createAsyncRequest(new URI(baseUrl + "/echo"), HttpMethod.POST);
    final byte[] body = "Hello World".getBytes("UTF-8");

    if (request instanceof StreamingHttpOutputMessage) {
      StreamingHttpOutputMessage streamingRequest = (StreamingHttpOutputMessage) request;
      streamingRequest.setBody(outputStream -> StreamUtils.copy(body, outputStream));
    }
    else {
      StreamUtils.copy(body, request.getBody());
    }
View Full Code Here

    String headerValue2 = "value2";
    request.getHeaders().add(headerName, headerValue2);
    final byte[] body = "Hello World".getBytes("UTF-8");
    request.getHeaders().setContentLength(body.length);
    if (request instanceof StreamingHttpOutputMessage) {
      StreamingHttpOutputMessage streamingRequest =
          (StreamingHttpOutputMessage) request;
      streamingRequest.setBody(new StreamingHttpOutputMessage.Body() {
        @Override
        public void writeTo(OutputStream outputStream) throws IOException {
          StreamUtils.copy(body, outputStream);
        }
      });
View Full Code Here

  @Test(expected = IllegalStateException.class)
  public void multipleWrites() throws Exception {
    ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/echo"), HttpMethod.POST);
    final byte[] body = "Hello World".getBytes("UTF-8");
    if (request instanceof StreamingHttpOutputMessage) {
      StreamingHttpOutputMessage streamingRequest =
          (StreamingHttpOutputMessage) request;
      streamingRequest.setBody(new StreamingHttpOutputMessage.Body() {
        @Override
        public void writeTo(OutputStream outputStream) throws IOException {
          StreamUtils.copy(body, outputStream);
        }
      });
View Full Code Here

TOP

Related Classes of org.springframework.http.StreamingHttpOutputMessage

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.