FreeRTOS+TCP issue with prvSendReply when returning status code with no payload

I am working on an embedded rest api based on the FreeRTOS+TCP Labs Build 160919 http server. While I am waiting on the hardware for the project I am running my code under the windows simulator. I have observed an issue with the method prvSendReply method. Basically when code returns a 404 (not found) the browser timesout. This also occurs when there is any This is easy to reproduce by running the FreeRTOSPlusTCPandFATWindowsSimulator code and requesting a non existant file for example freertos.htmlx I have run a network trace and I can see the http response packets being transmitted and acked. It appears that there is something specific to the contents of the response that the browser does not like. I have used IE, firefox, chrome and all exhibit the same issue. I have modified the response to use content lenght header, connection close etc but have been unable to prevent the browser timeout. I am looking for any pointers as to what the problem might be and how to resolve as for my project I will be returing status codes only for a number of api calls. Thanks.

FreeRTOS+TCP issue with prvSendReply when returning status code with no payload

For anyone interested there is a bug in FreeRTOSHTTPserver.c The Content-Length header is not set when a http response code is being returned that has no content. Browsers seem to have an issue with this payload it looks like they are waiting for more content. Adding the content Content-Length header with a value of 0 prior to the call to prvSendReply @Line 308 in FreeRTOSHTTPserver.c for FreeRTOS+TCP Labs Build 160919 will resolve the browser hang. ~~~ if( pxClient->pxFileHandle == NULL ) { strcpy( pxClient->pxParent->pcExtraContents, “Content-Length: 0rn” ); /* “404 File not found”. */ xRc = prvSendReply( pxClient, WEB_NOT_FOUND ); } else { pxClient->uxBytesLeft = ( size_t ) pxClient->pxFileHandle->ulFileSize; xRc = prvSendFile( pxClient ); } ~~~ Also the Content-Length header must be post fixed with rn

FreeRTOS+TCP issue with prvSendReply when returning status code with no payload

Hi Derek, sorry for my late response. I’m travelling around till next week. Thanks a lot for reporting this. Sounds plausible that a content length of zero must be transmitted.

FreeRTOS+TCP issue with prvSendReply when returning status code with no payload

Hey no problem. It did’nt take too long to figure out.