@@ -149,38 +149,38 @@ private HttpRequest buildRequest(HttpHeaders headers, @Nullable Body body) {
149
149
}
150
150
});
151
151
152
- switch (this .method .name ()) {
153
- case "GET" :
154
- builder .GET ();
155
- break ;
156
- case "DELETE" :
157
- builder .DELETE ();
158
- break ;
159
- default :
160
- builder .method (this .method .name (), bodyPublisher (headers , body ));
152
+ if (body != null ) {
153
+ builder .method (this .method .name (), bodyPublisher (headers , body ));
154
+ }
155
+ else {
156
+ switch (this .method .name ()) {
157
+ case "GET" :
158
+ builder .GET ();
159
+ break ;
160
+ case "DELETE" :
161
+ builder .DELETE ();
162
+ break ;
163
+ default :
164
+ builder .method (this .method .name (), HttpRequest .BodyPublishers .noBody ());
165
+ }
161
166
}
162
167
return builder .build ();
163
168
}
164
169
165
- private HttpRequest .BodyPublisher bodyPublisher (HttpHeaders headers , @ Nullable Body body ) {
166
- if (body != null ) {
167
- Flow .Publisher <ByteBuffer > publisher = new OutputStreamPublisher <>(
168
- os -> body .writeTo (StreamUtils .nonClosing (os )), BYTE_MAPPER , this .executor , null );
170
+ private HttpRequest .BodyPublisher bodyPublisher (HttpHeaders headers , Body body ) {
171
+ Flow .Publisher <ByteBuffer > publisher = new OutputStreamPublisher <>(
172
+ os -> body .writeTo (StreamUtils .nonClosing (os )), BYTE_MAPPER , this .executor , null );
169
173
170
- long contentLength = headers .getContentLength ();
171
- if (contentLength > 0 ) {
172
- return HttpRequest .BodyPublishers .fromPublisher (publisher , contentLength );
173
- }
174
- else if (contentLength == 0 ) {
175
- return HttpRequest .BodyPublishers .noBody ();
176
- }
177
- else {
178
- return HttpRequest .BodyPublishers .fromPublisher (publisher );
179
- }
174
+ long contentLength = headers .getContentLength ();
175
+ if (contentLength > 0 ) {
176
+ return HttpRequest .BodyPublishers .fromPublisher (publisher , contentLength );
180
177
}
181
- else {
178
+ else if ( contentLength == 0 ) {
182
179
return HttpRequest .BodyPublishers .noBody ();
183
180
}
181
+ else {
182
+ return HttpRequest .BodyPublishers .fromPublisher (publisher );
183
+ }
184
184
}
185
185
186
186
/**
0 commit comments