File tree Expand file tree Collapse file tree 2 files changed +47
-14
lines changed
main/java/org/springframework/http/client
test/java/org/springframework/http/client Expand file tree Collapse file tree 2 files changed +47
-14
lines changed Original file line number Diff line number Diff line change @@ -55,21 +55,23 @@ public URI getURI() {
55
55
protected ClientHttpResponse executeInternal (HttpHeaders headers , byte [] bufferedOutput ) throws IOException {
56
56
this .request .getHeaders ().putAll (headers );
57
57
58
- if (this .request instanceof StreamingHttpOutputMessage streamingHttpOutputMessage ) {
59
- streamingHttpOutputMessage .setBody (new StreamingHttpOutputMessage .Body () {
60
- @ Override
61
- public void writeTo (OutputStream outputStream ) throws IOException {
62
- StreamUtils .copy (bufferedOutput , outputStream );
63
- }
58
+ if (bufferedOutput .length > 0 ) {
59
+ if (this .request instanceof StreamingHttpOutputMessage streamingHttpOutputMessage ) {
60
+ streamingHttpOutputMessage .setBody (new StreamingHttpOutputMessage .Body () {
61
+ @ Override
62
+ public void writeTo (OutputStream outputStream ) throws IOException {
63
+ StreamUtils .copy (bufferedOutput , outputStream );
64
+ }
64
65
65
- @ Override
66
- public boolean repeatable () {
67
- return true ;
68
- }
69
- });
70
- }
71
- else {
72
- StreamUtils .copy (bufferedOutput , this .request .getBody ());
66
+ @ Override
67
+ public boolean repeatable () {
68
+ return true ;
69
+ }
70
+ });
71
+ }
72
+ else {
73
+ StreamUtils .copy (bufferedOutput , this .request .getBody ());
74
+ }
73
75
}
74
76
75
77
ClientHttpResponse response = this .request .execute ();
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2002-2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org .springframework .http .client ;
18
+
19
+ /**
20
+ * Tests for {@link BufferingClientHttpRequestWrapper} for clients
21
+ * not supporting non-null, empty request bodies for GET requests.
22
+ */
23
+ class BufferingClientHttpRequestFactoryWithOkHttpTests extends AbstractHttpRequestFactoryTests {
24
+
25
+ @ Override
26
+ @ SuppressWarnings ("removal" )
27
+ protected ClientHttpRequestFactory createRequestFactory () {
28
+ return new BufferingClientHttpRequestFactory (new OkHttp3ClientHttpRequestFactory ());
29
+ }
30
+
31
+ }
You can’t perform that action at this time.
0 commit comments