tass-belgium / picotcp-modules

Application level modules to run on top of the popular Embedded picoTCP TCP/IP stack
GNU General Public License v2.0
8 stars 11 forks source link

HTTP client doesn't close connection if connection type is close. #10

Open VincentDeHaen opened 8 years ago

VincentDeHaen commented 8 years ago

HTTP trace: GET /plugin/CILamp/jobs?MAC=02-BA-BE-BA-BE-02 HTTP/1.1 Host: 192.168.3.1:8080 User-Agent: picoTCP Connection: Close

HTTP/1.1 200 OK X-Content-Type-Options: nosniff Content-Type: text/html;charset=UTF-8 Connection: close Server: Jetty(winstone-2.9)

{"Name":"jelly","Colour":"Green","Flash":"SOLID"}

In Wireshark: jenkinsnotnice

The client acknowledges the response and then the connection stays open. If I read the RFC rules right client should close the connection himself (correct me if i'm wrong). Most of the servers do this by themselves and then there are no problems.

These packages were captured using a Jenkins server and the lamp application. I'm using very similar code as the one provided in the User Documentation. Is there a way to solve this?

robbinvandamme commented 8 years ago

No, you are correct: A client that sends a "close" connection option MUST NOT send further requests on that connection (after the one containing "close") and MUST close the connection after reading the final response message corresponding to this request.

So we need to call: pico_http_client_close(client->connectionID); after the client-app has read the response. (somewhere around line 1860 in "if (client->body_read_done)")