test/cmd/wget: replace bogus response with an actual response from the HTTP server
authorMikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Sat, 28 Dec 2024 10:46:34 +0000 (13:46 +0300)
committerTom Rini <trini@konsulko.com>
Sat, 28 Dec 2024 17:59:42 +0000 (11:59 -0600)
commitece1631f5e1d12477a9fd439570a3f05e4e8fb1e
tree2515083301f67fcf28f878c110d54c1161e35009
parentfa3ae38b837e24d468b59f0c96b8172f47ba0ceb
test/cmd/wget: replace bogus response with an actual response from the HTTP server

According to HTTP/1.0 standard the HTTP reply consist of
 * Status Line + CRLF
 * Zero or more Response Header Fields (each ended with CRLF)
 * CRLF on new line (Response Header Fields end marker)
 * Optional Entity Body.

Thus in response headers we state:
  Content-Length = 30
but actual transferred file data is:
  "\r\n<html><body>Hi</body></html>\r\n".
This is 32 bytes of data.

So we get and check for correctness 32 bytes of data, but
 * The response we are used is incorrect, real server will
   set Content-Length to 32.
 * default_wget_info->hdr_cont_len will be set to wrong
   value 30 (used for efi http booting).

Fix an issue by:
 * replace bogus response with an actual response from the HTTP server
 * format response to show HTTP response structure
 * recalculate md5sum as transferred file data has been changed.

The server response was captured with the commands

  echo -ne "<html><body>Hi</body></html>\n" > ~/public_html/test.html
  echo -ne "GET /~${USER}/test.html HTTP/1.0\r\n\r\n" | netcat localhost 80 >reply.txt

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
test/cmd/wget.c