3 ms·
How would using curl -d make the problem obvious?
by spuz 5y ago
How would using curl -d make the problem obvious?
- barrkel 5y agoIt wouldn't have split the request over separate sends. That's what flushHeaders() is doing; it does a separate send for headers vs the body of the request. https://nodejs.org/api/http.html#http_request_flushheaders https://nodejs.org/api/http.html#http_request_flushheaders
- spuz 5y agoOk, I think that would have helped me learn that the client can some how trigger the bug but I don't think it would have allowed me to narrow it down to flushHeaders.
- gizmo 5y agoThere is no such thing as flushing a TCP socket which is why that function jumped out at me. curl would have confirmed the server isn't misbehaving. Googling flushHeaders shows it's a node implementation specific thing and the docs explain that it has to do with the way node buffers http headers. Which makes sense because you don't want to call socket.send() for every http header you add to your request. But you also don't want to send() in between your headers and the body, because then you violate TCP package size expectations.
- adenhoed 5y agoflushHeaders() is there to have a simple bug to find. In real world cases, tools like tcpdump and strace are essential, and I think this is a nice way to teach about how these tools can be used.