5
5
"github.com/dghubble/sling"
6
6
. "github.com/onsi/ginkgo"
7
7
. "github.com/onsi/gomega"
8
- "io/ioutil "
8
+ "io"
9
9
"net/http"
10
10
"net/http/httptest"
11
11
)
@@ -87,7 +87,7 @@ var _ = Describe("When I run Hoverfly", func() {
87
87
response := hoverfly .Proxy (sling .New ().Get ("https://hoverfly.io/path" ))
88
88
Expect (response .StatusCode ).To (Equal (http .StatusOK ))
89
89
90
- body , err := ioutil .ReadAll (response .Body )
90
+ body , err := io .ReadAll (response .Body )
91
91
Expect (err ).To (BeNil ())
92
92
Expect (string (body )).To (Equal ("OK" ))
93
93
@@ -131,7 +131,7 @@ var _ = Describe("When I run Hoverfly", func() {
131
131
response := hoverfly .Proxy (sling .New ().Get ("https://hoverfly.io/path" ))
132
132
Expect (response .StatusCode ).To (Equal (http .StatusOK ))
133
133
134
- body , err := ioutil .ReadAll (response .Body )
134
+ body , err := io .ReadAll (response .Body )
135
135
Expect (err ).To (BeNil ())
136
136
Expect (string (body )).To (Equal ("OK" ))
137
137
@@ -173,7 +173,7 @@ var _ = Describe("When I run Hoverfly", func() {
173
173
response := hoverfly .Proxy (sling .New ().Get ("https://hoverfly.io/path" ))
174
174
Expect (response .StatusCode ).To (Equal (http .StatusOK ))
175
175
176
- body , err := ioutil .ReadAll (response .Body )
176
+ body , err := io .ReadAll (response .Body )
177
177
Expect (err ).To (BeNil ())
178
178
Expect (string (body )).To (Equal ("OK" ))
179
179
@@ -183,6 +183,51 @@ var _ = Describe("When I run Hoverfly", func() {
183
183
Expect (response .ContentLength ).To (Equal (int64 (- 1 )))
184
184
Expect (response .TransferEncoding ).To (Equal ([]string {"chunked" }))
185
185
})
186
+
187
+ It ("should not set transfer encoding header for 204 response" , func () {
188
+
189
+ hoverfly .ImportSimulation (`{
190
+ "data": {
191
+ "pairs": [
192
+ {
193
+ "request": {
194
+ "path": [
195
+ {
196
+ "matcher": "exact",
197
+ "value": "/path"
198
+ }
199
+ ],
200
+ "scheme": [
201
+ {
202
+ "matcher": "exact",
203
+ "value": "https"
204
+ }
205
+ ]
206
+ },
207
+ "response": {
208
+ "status": 204,
209
+ "body": ""
210
+ }
211
+ }
212
+ ]
213
+ },
214
+ "meta": {
215
+ "schemaVersion": "v5.2"
216
+ }
217
+ }` )
218
+ response := hoverfly .Proxy (sling .New ().Get ("https://hoverfly.io/path" ))
219
+ Expect (response .StatusCode ).To (Equal (http .StatusNoContent ))
220
+
221
+ body , err := io .ReadAll (response .Body )
222
+ Expect (err ).To (BeNil ())
223
+ Expect (string (body )).To (Equal ("" ))
224
+
225
+ Expect (response .Header .Get ("Content-Length" )).To (Equal ("" ))
226
+ Expect (response .Header .Get ("Transfer-Encoding" )).To (Equal ("" ))
227
+
228
+ Expect (response .ContentLength ).To (Equal (int64 (0 )))
229
+ Expect (response .TransferEncoding ).To (BeNil ())
230
+ })
186
231
})
187
232
188
233
Context ("and it uses default certificate and key configuration" , func () {
0 commit comments