Hi,
My code uses HTTPClient (actually this fork: http://mbed.org/users/ollie8/code/HTTPClient/) to read a value from a very small file on a web server. The call:
HTTPResult r = http.get( "http://192.168.1.245/mbed/VERSION.TXT", ver, 10 );
doesn't return until the timeout occurs.
I believe it is caused by this piece of code in HTTPClient.cpp:
Receive response
DBG("Receiving response");
ret = recv(buf, CHUNK_SIZE - 1, CHUNK_SIZE - 1, &trfLen); Read n bytes
which tells recv to return a minimum of 255 bytes, and a maximum of 255 bytes. If I change that last line to:
ret = recv(buf, 1, CHUNK_SIZE - 1, &trfLen); Read n bytes
then the file contents is retrieved much quicker, without waiting for the timeout.
Really, it should keep receiving bytes until the whole header has been received...
Rob.
Hi,
My code uses HTTPClient (actually this fork: http://mbed.org/users/ollie8/code/HTTPClient/) to read a value from a very small file on a web server. The call:
HTTPResult r = http.get( "http://192.168.1.245/mbed/VERSION.TXT", ver, 10 );
doesn't return until the timeout occurs.
I believe it is caused by this piece of code in HTTPClient.cpp:
Receive response DBG("Receiving response"); ret = recv(buf, CHUNK_SIZE - 1, CHUNK_SIZE - 1, &trfLen); Read n bytes
which tells recv to return a minimum of 255 bytes, and a maximum of 255 bytes. If I change that last line to:
ret = recv(buf, 1, CHUNK_SIZE - 1, &trfLen); Read n bytes
then the file contents is retrieved much quicker, without waiting for the timeout.
Really, it should keep receiving bytes until the whole header has been received...
Rob.