Dynamic content - Receiving data through POST

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi There,

I am having a bit of a problem which I am pretty sure is my fault 🙂

I am trying to implement FW upgrade in my application, much like the OTA application, but using standard HTTP server. I am trying to send data chunk via POST method.

I eventually end up in my dynamic content handler. The wiced_http_message_body_t * http_data shows:

ttp_data->message_data_length = 0x00000000

http_data->total_message_data_remaining = 0x00000400

http_data->chunked_transfer = 0x00000000

I then  simply allocate a buffer of size equal to http_data->total_message_data_remaining, read data by doing:

if (wiced_tcp_stream_read(stream, pBuf, http_data->total_message_data_remaining, 2000) != WICED_SUCCESS) {

     printf("wiced_tcp_stream_read() failed\n");

}


free the buffer and returns.

Client get the OK and sends second data chunk but my device is actually stuck after returning from my handler and this until watchdog resets.

I am pretty sure that I am not doing something right, or probably forgetting to do something. Is wiced_tcp_stream_read() the correct way to get data from a POST ? Is there anything else I need to do after calling wiced_tcp_stream_read() ? I have tried to look at the OTA server sources but it is much different and did not find what I was looking for.

Oh, and yes I am not HTTP protocol expert 😉

Thanks much.


8 Replies
Anonymous
Not applicable

Anybody can help me getting data from POST  ?

0 Likes
Anonymous
Not applicable

I am still having same issue with 3.1.2

0 Likes
Anonymous
Not applicable

Feels real nice having a conversation with myself 🙂

I traced the problem to the HTTP server:

http_server_parse_packet() line 444 with the call of wiced_http_server_set_http_message_body_type_for_socket()


POST is viewed as a transaction with data split across packet, dynamic content API get that data using wiced_tcp_stream_read(), when it returns, server tries to handle second part of that transaction, which does not exist, HTTP server hangs.


I worked around this by not calling wiced_http_server_set_http_message_body_type_for_socket() if the request is a "POST", it seems to be "good enough" for me, but I would really like to get advice from a network expert.

Thanks.

Guillaume

Anonymous
Not applicable

Did you try it with ThreadX+NetX?

Because FreeRTOS+LwIP seems to have similar problem like you

But ThreadX +Lwip works fine to me

FreeRtos and Lwip seems to close socket .

I am not sure.

I tested with SDK 1.3.1

Tks

0 Likes
Anonymous
Not applicable

I'm using ThreadX and NetX duo, I don't think it is a OS/Stack issue, I is most probably a HTTP server problem.

0 Likes

Can you create a new discussion if this is still an issue in 3.1.2?

0 Likes
Anonymous
Not applicable

This is still an issue with released SDK, that can be address with the fix I described. I doubt duplicating post in the forum is the best way to address this, it might confuse people.

Thanks.

0 Likes
Anonymous
Not applicable

Hi Guys,

Did you notice how strstr function is used in HTTP server, i.e:

result = wiced_http_server_get_packet_data( socket, packet, &request_string, &request_length );

...

if ( strstr( request_string, HTTP_HEADER_CLOSE ) != NULL )

...

The problem is request_string is non-null terminated.

Oleg

0 Likes