@@ -220,64 +220,61 @@ else if (uri.getRawQuery() != null)
220
220
headers .put (HttpHeaders .Names .COOKIE , CookieEncoder .encodeClientSide (request .getCookies (), config .isRfc6265CookieEncoding ()));
221
221
}
222
222
223
- if (method != HttpMethod .HEAD && method != HttpMethod .OPTIONS && method != HttpMethod .TRACE ) {
224
-
225
- String bodyCharset = request .getBodyEncoding () == null ? DEFAULT_CHARSET : request .getBodyEncoding ();
226
-
227
- if (request .getByteData () != null ) {
228
- headers .put (HttpHeaders .Names .CONTENT_LENGTH , request .getByteData ().length );
229
- content = Unpooled .wrappedBuffer (request .getByteData ());
230
-
231
- } else if (request .getStringData () != null ) {
232
- byte [] bytes = request .getStringData ().getBytes (bodyCharset );
233
- headers .put (HttpHeaders .Names .CONTENT_LENGTH , bytes .length );
234
- content = Unpooled .wrappedBuffer (bytes );
235
-
236
- } else if (request .getStreamData () != null ) {
237
- hasDeferredContent = true ;
238
- headers .put (HttpHeaders .Names .TRANSFER_ENCODING , HttpHeaders .Values .CHUNKED );
239
-
240
- } else if (isNonEmpty (request .getParams ())) {
241
- StringBuilder sb = new StringBuilder ();
242
- for (final Entry <String , List <String >> paramEntry : request .getParams ()) {
243
- final String key = paramEntry .getKey ();
244
- for (final String value : paramEntry .getValue ()) {
245
- UTF8UrlEncoder .appendEncoded (sb , key );
246
- sb .append ("=" );
247
- UTF8UrlEncoder .appendEncoded (sb , value );
248
- sb .append ("&" );
249
- }
223
+ String bodyCharset = request .getBodyEncoding () == null ? DEFAULT_CHARSET : request .getBodyEncoding ();
224
+
225
+ if (request .getByteData () != null ) {
226
+ headers .put (HttpHeaders .Names .CONTENT_LENGTH , request .getByteData ().length );
227
+ content = Unpooled .wrappedBuffer (request .getByteData ());
228
+
229
+ } else if (request .getStringData () != null ) {
230
+ byte [] bytes = request .getStringData ().getBytes (bodyCharset );
231
+ headers .put (HttpHeaders .Names .CONTENT_LENGTH , bytes .length );
232
+ content = Unpooled .wrappedBuffer (bytes );
233
+
234
+ } else if (request .getStreamData () != null ) {
235
+ hasDeferredContent = true ;
236
+ headers .put (HttpHeaders .Names .TRANSFER_ENCODING , HttpHeaders .Values .CHUNKED );
237
+
238
+ } else if (isNonEmpty (request .getParams ())) {
239
+ StringBuilder sb = new StringBuilder ();
240
+ for (final Entry <String , List <String >> paramEntry : request .getParams ()) {
241
+ final String key = paramEntry .getKey ();
242
+ for (final String value : paramEntry .getValue ()) {
243
+ UTF8UrlEncoder .appendEncoded (sb , key );
244
+ sb .append ("=" );
245
+ UTF8UrlEncoder .appendEncoded (sb , value );
246
+ sb .append ("&" );
250
247
}
251
- sb .setLength (sb .length () - 1 );
252
- byte [] bytes = sb .toString ().getBytes (bodyCharset );
253
- headers .put (HttpHeaders .Names .CONTENT_LENGTH , bytes .length );
254
- content = Unpooled .wrappedBuffer (bytes );
248
+ }
249
+ sb .setLength (sb .length () - 1 );
250
+ byte [] bytes = sb .toString ().getBytes (bodyCharset );
251
+ headers .put (HttpHeaders .Names .CONTENT_LENGTH , bytes .length );
252
+ content = Unpooled .wrappedBuffer (bytes );
255
253
256
- if (!request .getHeaders ().containsKey (HttpHeaders .Names .CONTENT_TYPE )) {
257
- headers .put (HttpHeaders .Names .CONTENT_TYPE , HttpHeaders .Values .APPLICATION_X_WWW_FORM_URLENCODED );
258
- }
254
+ if (!request .getHeaders ().containsKey (HttpHeaders .Names .CONTENT_TYPE )) {
255
+ headers .put (HttpHeaders .Names .CONTENT_TYPE , HttpHeaders .Values .APPLICATION_X_WWW_FORM_URLENCODED );
256
+ }
259
257
260
- } else if (request .getParts () != null ) {
261
- // FIXME use Netty multipart
262
- MultipartRequestEntity mre = AsyncHttpProviderUtils .createMultipartRequestEntity (request .getParts (), request .getHeaders ());
258
+ } else if (request .getParts () != null ) {
259
+ // FIXME use Netty multipart
260
+ MultipartRequestEntity mre = AsyncHttpProviderUtils .createMultipartRequestEntity (request .getParts (), request .getHeaders ());
263
261
264
- headers .put (HttpHeaders .Names .CONTENT_TYPE , mre .getContentType ());
265
- if (mre .getContentLength () >= 0 ) {
266
- headers .put (HttpHeaders .Names .CONTENT_LENGTH , mre .getContentLength ());
267
- }
268
- hasDeferredContent = true ;
269
-
270
- } else if (request .getFile () != null ) {
271
- File file = request .getFile ();
272
- if (!file .isFile ()) {
273
- throw new IOException (String .format ("File %s is not a file or doesn't exist" , file .getAbsolutePath ()));
274
- }
275
- headers .put (HttpHeaders .Names .CONTENT_LENGTH , file .length ());
276
- hasDeferredContent = true ;
262
+ headers .put (HttpHeaders .Names .CONTENT_TYPE , mre .getContentType ());
263
+ if (mre .getContentLength () >= 0 ) {
264
+ headers .put (HttpHeaders .Names .CONTENT_LENGTH , mre .getContentLength ());
265
+ }
266
+ hasDeferredContent = true ;
277
267
278
- } else if (request .getBodyGenerator () != null ) {
279
- hasDeferredContent = true ;
268
+ } else if (request .getFile () != null ) {
269
+ File file = request .getFile ();
270
+ if (!file .isFile ()) {
271
+ throw new IOException (String .format ("File %s is not a file or doesn't exist" , file .getAbsolutePath ()));
280
272
}
273
+ headers .put (HttpHeaders .Names .CONTENT_LENGTH , file .length ());
274
+ hasDeferredContent = true ;
275
+
276
+ } else if (request .getBodyGenerator () != null ) {
277
+ hasDeferredContent = true ;
281
278
}
282
279
}
283
280
0 commit comments