http: write last header line late

- HEADERFUNCTIONS might inspect response properties like
  CURLINFO_CONTENT_LENGTH_DOWNLOAD_T on seeing the last header line. If
  the line is being written before this is initialized, values are not
  available.

- write the last header line late when analyzing a HTTP response so that
  all information is available at the time of the writing.

- add test1485 to verify that CURLINFO_CONTENT_LENGTH_DOWNLOAD_T works
  on seeing the last header.

Fixes #13752
Reported-by: Harry Sintonen
Closes #13757
This commit is contained in:
Stefan Eissing 2024-05-23 12:21:46 +02:00 committed by Daniel Stenberg
parent 548d169c9c
commit 17af2bca58
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 247 additions and 32 deletions

View file

@ -188,7 +188,7 @@ test1447 test1448 test1449 test1450 test1451 test1452 test1453 test1454 \
test1455 test1456 test1457 test1458 test1459 test1460 test1461 test1462 \
test1463 test1464 test1465 test1466 test1467 test1468 test1469 test1470 \
test1471 test1472 test1473 test1474 test1475 test1476 test1477 test1478 \
test1479 test1480 test1481 test1482 test1483 test1484 \
test1479 test1480 test1481 test1482 test1483 test1484 test1485 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \

51
tests/data/test1485 Normal file
View file

@ -0,0 +1,51 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Server: Someone
Content-Length: 7
123456
</data>
<datacheck>
HTTP/1.1 200 OK
Server: Someone
Content-Length: 7
123456
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<tool>
lib%TESTNUMBER
</tool>
<name>
get curlinfo on last header in callback
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
</protocol>
</verify>
</testcase>