Skip to content

Commit 026b529

Browse files
committed
Fix big where encoded responses with a Content-Length where having their Content-Length measured against the encoded body, not decoded
1 parent e18f813 commit 026b529

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

core/import.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ func (hf *Hoverfly) importRequestResponsePairViews(pairViews []v2.RequestMatcher
159159

160160
if len(pairView.Response.Headers["Content-Length"]) > 0 {
161161
contentLength, err := strconv.Atoi(pairView.Response.Headers["Content-Length"][0])
162-
if err == nil && contentLength != len(pairView.Response.Body) {
162+
response := models.NewResponseDetailsFromResponse(pairView.Response)
163+
if err == nil && contentLength != len(response.Body) {
163164
importResult.AddContentLengthMismatchWarning(i)
164165
}
165166
}

core/import_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ func TestImportImportRequestResponsePairs_ReturnsWarningsContentLengthAndTransfe
726726
Body: base64String("hello_world"),
727727
EncodedBody: true,
728728
Headers: map[string][]string{
729-
"Content-Length": []string{"16"},
729+
"Content-Length": []string{"11"},
730730
"Transfer-Encoding": []string{"chunked"},
731731
},
732732
},

0 commit comments

Comments
 (0)