mirror of
https://github.com/curl/curl.git
synced 2026-06-03 16:54:22 +03:00
http: prefer chunked encoding over Content-Length: 0
Call http_size() before checking the request for empty body to prefer Transfer-Encoding: chunked even if Content-Length is 0. Closes #21706
This commit is contained in:
parent
28341c303d
commit
ba600296d2
3 changed files with 89 additions and 9 deletions
|
|
@ -222,7 +222,7 @@ test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
|
|||
test1658 test1659 test1660 test1661 test1662 test1663 test1664 test1665 \
|
||||
test1666 test1667 test1668 test1669 \
|
||||
\
|
||||
test1670 test1671 test1672 test1673 test1674 test1675 test1676 \
|
||||
test1670 test1671 test1672 test1673 test1674 test1675 test1676 test1677 \
|
||||
\
|
||||
test1680 test1681 test1682 test1683 test1684 test1685 \
|
||||
\
|
||||
|
|
|
|||
77
tests/data/test1677
Normal file
77
tests/data/test1677
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="US-ASCII"?>
|
||||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
HTTP POST
|
||||
chunked Transfer-Encoding
|
||||
Content-Length
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Regression test for bug where curl stops reading chunked response
|
||||
# when both Content-Length: 0 and Transfer-Encoding: chunked headers
|
||||
# are present. Per RFC 7230 Section 3.3.3, Transfer-Encoding should
|
||||
# take precedence and Content-Length should be ignored.
|
||||
# The writedelay simulates the timing issue where chunks arrive in
|
||||
# separate packets.
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<servercmd>
|
||||
writedelay: 500
|
||||
</servercmd>
|
||||
<data nocheck="yes" crlf="headers">
|
||||
HTTP/1.1 200 OK
|
||||
content-type: text/json
|
||||
connection: keep-alive
|
||||
content-length: 0
|
||||
transfer-encoding: chunked
|
||||
|
||||
1a
|
||||
random data in first chunk
|
||||
1d
|
||||
another data in second chunk
|
||||
15
|
||||
third and last chunk
|
||||
0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<name>
|
||||
HTTP POST response with both Transfer-Encoding chunked and Content-Length 0
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -d "testdata"
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol nonewline="yes" crlf="headers">
|
||||
POST /%TESTNUMBER HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
User-Agent: curl/%VERSION
|
||||
Accept: */*
|
||||
Content-Length: 8
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
testdata
|
||||
</protocol>
|
||||
<stdout nonewline="yes" crlf="headers">
|
||||
HTTP/1.1 200 OK
|
||||
content-type: text/json
|
||||
connection: keep-alive
|
||||
content-length: 0
|
||||
transfer-encoding: chunked
|
||||
|
||||
random data in first chunk another data in second chunk third and last chunk
|
||||
</stdout>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue