Commit 7c31335 Piotr Boniecki
committed
1 parent f7ac94d commit 7c31335 Copy full SHA for 7c31335
File tree 3 files changed +18
-9
lines changed
3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -160,14 +160,6 @@ def make_request_headers(opts)
160
160
headers [ Headers ::COOKIE ] = cookies
161
161
end
162
162
163
- if ( auto_deflate = opts . feature ( :auto_deflate ) )
164
- # We need to delete Content-Length header. It will be set automatically
165
- # by HTTP::Request::Writer
166
- headers . delete ( Headers ::CONTENT_LENGTH )
167
-
168
- headers [ Headers ::CONTENT_ENCODING ] = auto_deflate . method
169
- end
170
-
171
163
headers
172
164
end
173
165
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ def initialize(*)
20
20
21
21
def wrap_request ( request )
22
22
return request unless method
23
+ return request if request . body . size . zero?
24
+
25
+ # We need to delete Content-Length header. It will be set automatically by HTTP::Request::Writer
26
+ request . headers . delete ( Headers ::CONTENT_LENGTH )
27
+ request . headers [ Headers ::CONTENT_ENCODING ] = method
23
28
24
29
Request . new (
25
30
:version => request . version ,
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ def simple_response(body, status = 200)
234
234
235
235
context "when :auto_deflate was specified" do
236
236
let ( :headers ) { { "Content-Length" => "12" } }
237
- let ( :client ) { described_class . new :headers => headers , :features => { :auto_deflate => { } } }
237
+ let ( :client ) { described_class . new :headers => headers , :features => { :auto_deflate => { } } , body : "foo" }
238
238
239
239
it "deletes Content-Length header" do
240
240
expect ( client ) . to receive ( :perform ) do |req , _ |
@@ -251,6 +251,18 @@ def simple_response(body, status = 200)
251
251
252
252
client . request ( :get , "http://example.com/" )
253
253
end
254
+
255
+ context "and there is no body" do
256
+ let ( :client ) { described_class . new :headers => headers , :features => { :auto_deflate => { } } }
257
+
258
+ it "doesn't set Content-Encoding header" do
259
+ expect ( client ) . to receive ( :perform ) do |req , _ |
260
+ expect ( req . headers ) . not_to include "Content-Encoding"
261
+ end
262
+
263
+ client . request ( :get , "http://example.com/" )
264
+ end
265
+ end
254
266
end
255
267
end
256
268
You can’t perform that action at this time.
0 commit comments