0

I am working on my HTTP server and I applied chunked transfer encoding to my responses if the requested file is larger than 64K. It works fine with Firefox, I can even send large videos, but Chrome and Curl simply close the connection and don't display anything.

If I write my response to the file, the result is something like that:

HTTP/1.1 200 OK
Transfer-Encoding: chunked

0x3ff\r\n
a lot of text\r\n
0x41\r\n
less text\r\n
0\r\n
\r\n

Where to search for the problem? Should I add a content-type header? And why it works with Firefox and doesn't work with other browsers/utilities? Thank you in advance.

  • Is the `\r\n` a literal string? Or are they true CRLF characters? I'm suspicious because I don't see them in your headers – Evert Jul 15 '20 at 16:59
  • Oh I also don't think the chunk lengths should start with `0x`. Just remove that and try again – Evert Jul 15 '20 at 17:00
  • 1
    Yes, I removed 0x and everithing works fine. Thank you so much) I spent hours with gdb trying to solve this problem. – Olexandr Kulinich Jul 15 '20 at 17:19

1 Answers1

1

The issue was that the chunk-lengths were encoded as 0xFF, while they should have been encoded as FF.

Evert
  • 93,428
  • 18
  • 118
  • 189