If you are asking a question, please follow this template:
- My goal is:
[Would like to keep http connection open and continue sending POST request] - My actions are:
- Using the “Connection: keep-alive” in header during mg_connect_http() call, when MG_EV_HTTP_REPLY is received.
- Call mg_print(buffer)
char buffer [] =
“POST / HTTP/1.1\r\n
HOST: 192.168.1.4:443\r\n
Content-Type: text/html\r\n
Connection: keep-alive\r\n”
Content-Length: 10\r\n\r\n
{Test_ing}\r\n"
- The result I see is:
- mg_connect_http() for initial POST request
- events received :
MG_EV_CONNECT
MG_EV_SEND
MG_EV_HTTP_CHUNK
MG_EV_HTTP_REPLY
—> The connection does stay open in here
-
mg_print() for 2nd POST request
-
events received :
MG_EV_SEND
MG_EV_HTTP_CHUNK
MG_EV_HTTP_REPLY
MG_EV_CLOSE -
The connection close right after “MG_EV_HTTP_REPLY” is received
-
Have confirmed in connecting test server, it received both POST request contents.
- My expectation & question is:
I want the connection stay opened and can use mg_print to continue sending multiple POST request.