HTTP dynamic page can't be accessed twice

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

cross mob
Geva_2134536
Level 3
Level 3
First like received First like given

I have a dynamic page where data gets posted to in XML format, I can read this out and process it without any problem.

However when the page is called for the second time it is not reacting.

Looking with wireshark I can see that the connection is made and the packet is send but the dynamic function doesn't seem to get called.

My function is as following:

static int32_t process_join( const char* url_parameters, wiced_tcp_stream_t* stream, void* arg, wiced_http_message_body_t* http_message_body )

{

    WPRINT_APP_INFO(("Join called...\r\n"));

    uint16_t uiDataLen = 0;

    char acBuffer[300];

    char acType[20];

    uiDataLen = http_message_body->total_message_data_remaining;

    if((http_message_body->request_type == WICED_HTTP_POST_REQUEST) &&

            uiDataLen > 0)

    {

        WPRINT_APP_INFO(("POST\r\n"));

        wiced_result_t readResult = wiced_tcp_stream_read(stream, acBuffer, uiDataLen, 2000);

        if (readResult != WICED_SUCCESS) {

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

        }

        else

        {

           //Processing code here, even if commented can not call second time

        }

    }

    wiced_tcp_stream_write(stream,"<status>ok</status>",19);

    WPRINT_APP_INFO(("Stream done\r\n"));

    return 0;

}

It seems like the function stays in use or something because when I call the URL for the second time I also don't see the "Join called" text in my terminal.

Does anyone have a pointer for what is going wrong?

0 Likes
3 Replies
Geva_2134536
Level 3
Level 3
First like received First like given

I have done more testing and figured out some more info, I tested with calling the URL using "wget" in several ways.

Normally I would call the url like:

wget "http://192.168.1.1/gainspan/system/config/network" --post-file="test.xml" --header="Content-Type:application/xml"

Where test.xml holds the data I want to post, this only works for one time and the second time the problem as described above occurs, I can call the URL.

However when I don't post any data and execute the command like:

wget "http://192.168.1.1/gainspan/system/config/network" --header="Content-Type:application/xml"


There is no problem at all because no data is posted.


So I stripped my function to bare minimum:


static int32_t process_join( const char* url_parameters, wiced_tcp_stream_t* stream, void* arg, wiced_http_message_body_t* http_message_body )

{

    WPRINT_APP_INFO(("Join called...\r\n"));

    return 0;

}


But this still gives the same issue, when not posting the XML file as POST data it can be called multiple times.

When I call the url with the post data included I can only call the url once and after that it never works again...

Seems like something goes wrong with handling the post data before it arrives to the function.

Does anyone have a pointer on where to look for a solution for me?

UPDATE

I found out I am having the same issue as mentioned here:

Re: Dynamic content - Receiving data through POST

This workaround fixes it for me for now...


0 Likes

Hi,

Glad the work around is working for you at this time.

Will investigate further and fix the problem.

Seyhan

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