Skip to content

Commit be7dc56

Browse files
committed
Fix test for transfer-encoding:chunk
1 parent 5f8f72b commit be7dc56

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fsharp-backend/tests/TestUtils/TestUtils.fs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,24 +1053,27 @@ module Http =
10531053
&& String.toLowercase v = "chunked")
10541054
|> Option.isSome
10551055
if isTransferEncodingChunked then
1056-
print "have transferencoding header"
10571056
let decoder = new ChunkDecoder.Decoder()
1058-
print "created decider"
10591057
let mutable (byteArray : byte array) = null
1060-
print "created bytearray"
1061-
print $"body{body}"
1058+
// asp.net doesn't add the final sequence required by
1059+
// `transfer-encoding:chunked`, relying instead on closing the connection
1060+
// to indicate that the data in complete. However, the ChunkDecoder library
1061+
// does not support this, and hangs while waiting on the final chunk. We
1062+
// add the final chunk ourselves to allow the library to finish its work.
1063+
let body =
1064+
match body with
1065+
| [||] -> body
1066+
| body ->
1067+
let bytesToAppend = UTF8.toBytes "0\r\n"
1068+
Array.append body bytesToAppend
10621069
let success = decoder.Decode(body, &byteArray)
1063-
print $"decoded {success}"
10641070
if not success then Exception.raiseInternal "could not dechunk chunks" []
1065-
print "done dechunking"
10661071
byteArray
10671072
else
10681073
body
10691074
else
10701075
body
10711076

1072-
1073-
print $"stating to dezip {contentEncodingHeader}"
10741077
match contentEncodingHeader with
10751078
| Some "gzip" ->
10761079
let inputStream = new MemoryStream(body)

0 commit comments

Comments
 (0)