Hi Sergey! Hi everybody!
For a personal project of mine, I am trying to send http requests to an external web/cgi server. I managed to connect to the remote server with mg_connect() and get the event handler called with MG_CONNECT event. However, I wasn't able to forge a correct http GET request to a simple web server. I do get the request to be sent via my eth0 interface (I verified that with wireshark), but both the request and the response I get looks strange.
I could copy/paste them here, but that would be quite a lot of text... Instead, it would suffice to have a little more documentation on how mg_connect() work and how a client is expected to work with mongoose. In particular, since my application is supposed to serve local files and CGIs also, I would like to know if it is a good idea to use two separate mongoose servers to handle incoming and outgoing requests, or it is ok to use a single server for both.
Another critical question is: what are the correct return codes to be used in the event handler for MG_CONNECT, MG_REPLY and MG_CLOSE events? And, last but not least, what is the correct way to forge and send the http request? I am trying by sending text with mg_send_data(), but I am not sure I am doing it right. An insight of how mg_poll_server() works with outgoing requests would also be helpful.
Thanks in advance for your help!