Open FulvioSpelta opened 11 years ago
My solution in sketch:
I've defined an "Expect" header:
const char\* headers[] = {
"Content-Length",
"Expect",
NULL
};
then in POST handling function I've added the code:
const char\* expectHeader = web_server.get_header_value("Expect");
// Handle the optional presence of Expect: 100-Continue
if ((strcmp(expectHeader , "100-Continue") == 0) {
web_server.write( "HTTP/1.1 100 Continue\n\n" );
startTime = millis();
// wait for response till timeout
while( millis()-startTime <= CONTINUE_TIMEOUT && !client.available()) {};
};
Comments welcome :-) The problem with this code is that you're blocking the web server for the duration of CONTINUE_TIMEOUT, which means no other requests can be served during that time.
A better approach is to add a timer class that's initialized with a timeout value. Upon the execution of the run loop you check the values of all timers, and take the appropriate action when a timeout occurs.
There is a bug in application, that generates traffic you dumped. It should terminate HTTP/1.1 100 continue
with \r\n\r\n
instead of \n\n
Using POST request from httpclient Apache (my test client is openremote controller) I've found that their http 1.1 implementation ask for a "100-Continue" return code before sending the body request. See the example (I've "hard modified the code to send the "100-Continue" server answer in order to complete the request):
Client 1st request:
Server answer: Client 2nd request (request body): Server answer: Could you insert this handling into the library as standard POST request handling? thanks More details in hex form of all packet: