@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2017 the original author or authors .
* Copyright 2002 - 2019 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -27,6 +27,7 @@ import org.springframework.http.HttpHeaders;
@@ -27,6 +27,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.ResponseEntity ;
import org.springframework.http.StreamingHttpOutputMessage ;
import org.springframework.http.client.ClientHttpRequest ;
import org.springframework.http.client.ClientHttpResponse ;
import org.springframework.lang.Nullable ;
@ -182,7 +183,13 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
@@ -182,7 +183,13 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
public void doWithRequest ( ClientHttpRequest request ) throws IOException {
request . getHeaders ( ) . putAll ( this . headers ) ;
if ( this . body ! = null ) {
StreamUtils . copy ( this . body , SockJsFrame . CHARSET , request . getBody ( ) ) ;
if ( request instanceof StreamingHttpOutputMessage ) {
( ( StreamingHttpOutputMessage ) request ) . setBody ( outputStream - >
StreamUtils . copy ( this . body , SockJsFrame . CHARSET , outputStream ) ) ;
}
else {
StreamUtils . copy ( this . body , SockJsFrame . CHARSET , request . getBody ( ) ) ;
}
}
}
}