W5100s - Difference between HTTP request using cURL and a web browser?

I have an HTTP server running based on the following example: RP2040-HAT-C/examples/http/server/w5x00_http_server.c at main · Wiznet/RP2040-HAT-C · GitHub.

When I make a request using a web browser, for example, Firefox or even a command-line based browser like links, I get a correct response from the server every time. It also works well if using Postman for testing. However, if I use cURL, every other call will get curl: (52) Empty reply from server.

Is there any underlying difference between an application doing an HTTP request and a simpler command line tool doing the same?

Furthermore, from the server logs, I realized that:

  • Firefox: receives all responses correctly, and there’s only one socket connected per request.
  • Links: receives all responses correctly, and there are two sockets connected per request.
  • cURL: fails to receive a response every other call, and there’s only one socket connected per request.

In order to get the very same response I went to the network analyzer in Firefox and copied the HTTP request from there so that the exact same headers are used. I verified from the logs that the payload the server received is always the same when running Firefox and cURL.

I analyzed the payload that the server receives and it’s exactly the same. However, I found out that when using cURL the socket register status changes before finishing the complete response from socket ESTABILISHED to CLOSE_WAIT. Therefore, the socket process doesn’t complete since it never reaches the DONE status, and it requires another request where instead of processing the request it just closes the previous pending operation. When I use Firefox or anything else, this doesn’t happen and everything works normal, as expected.

What else could be affecting the behavior?