@@ -125,6 +125,28 @@ public function testGzipResponse()
125
125
$ this ->assertEquals ('f24dd075ba2ebfb3bf21270e3fdc5303 ' , md5 ($ res ->getContent ()));
126
126
}
127
127
128
+ public function testGzipResponseWithEmptyBody ()
129
+ {
130
+ $ responseTest = <<<'REQ'
131
+ HTTP/1.1 200 OK
132
+ Date: Sun, 25 Jun 2006 19:36:47 GMT
133
+ Server: Apache
134
+ X-powered-by: PHP/5.1.4-pl3-gentoo
135
+ Content-encoding: gzip
136
+ Vary: Accept-Encoding
137
+ Content-length: 0
138
+ Connection: close
139
+ Content-type: text/html
140
+
141
+ REQ;
142
+
143
+ $ res = Response::fromString ($ responseTest );
144
+
145
+ $ this ->assertEquals ('gzip ' , $ res ->getHeaders ()->get ('Content-encoding ' )->getFieldValue ());
146
+ $ this ->assertSame ('' , $ res ->getBody ());
147
+ $ this ->assertSame ('' , $ res ->getContent ());
148
+ }
149
+
128
150
public function testDeflateResponse ()
129
151
{
130
152
$ responseTest = file_get_contents (__DIR__ . '/_files/response_deflate ' );
@@ -136,6 +158,28 @@ public function testDeflateResponse()
136
158
$ this ->assertEquals ('ad62c21c3aa77b6a6f39600f6dd553b8 ' , md5 ($ res ->getContent ()));
137
159
}
138
160
161
+ public function testDeflateResponseWithEmptyBody ()
162
+ {
163
+ $ responseTest = <<<'REQ'
164
+ HTTP/1.1 200 OK
165
+ Date: Sun, 25 Jun 2006 19:38:02 GMT
166
+ Server: Apache
167
+ X-powered-by: PHP/5.1.4-pl3-gentoo
168
+ Content-encoding: deflate
169
+ Vary: Accept-Encoding
170
+ Content-length: 0
171
+ Connection: close
172
+ Content-type: text/html
173
+
174
+ REQ;
175
+
176
+ $ res = Response::fromString ($ responseTest );
177
+
178
+ $ this ->assertEquals ('deflate ' , $ res ->getHeaders ()->get ('Content-encoding ' )->getFieldValue ());
179
+ $ this ->assertSame ('' , $ res ->getBody ());
180
+ $ this ->assertSame ('' , $ res ->getContent ());
181
+ }
182
+
139
183
/**
140
184
* Make sure wer can handle non-RFC complient "deflate" responses.
141
185
*
0 commit comments