AnsweredAssumed Answered

Parse HTTP header

Question asked by zavodny.vilem on Apr 2, 2014
Latest reply on Apr 3, 2014 by waclawek.jan
Hi,
I use LwIP stack with FreeRTOS and STM32F4 Discovery. I use it like web server. And I want parse POST parameters. And parse header for read Cookies. I wrote lot of functions. Some functions was good in one browser, but in other browsers was problem. I don't know why? 

For example this function: 

int POST_parametry(char* uri){
     
    char* params_uri;
  char* equals;
    char* pair;
    char* pair1;
    char* cookie;
  int loop;
    int stop = 1;
     
    params_uri = strstr(uri, "\r\n\r\n");
     
    pair = params_uri+4;
     
        for(loop=0; (loop < LWIP_HTTPD_MAX_CGI_PARAMETERS) && pair; loop++){
 
            p_params[loop] = pair;
 
            equals = pair;
 
            pair = strchr(pair, '&');
            if(pair) {
                *pair = '\0';
                pair++;
            } else {
                    pair = strchr(equals, ' ');
                    if(pair) {
                            *pair = '\0';
                    }
 
                    pair = NULL;
            }
 
            equals = strchr(equals, '=');
            if(equals) {
                *equals = '\0';
                p_values[loop] = equals + 1;
            } else {
                p_values[loop] = NULL;
            }
        }
     
         
    return loop;
}

Sometimes parsed data isn't correct. 

Can you help me please? Or post some function for parse data? 

I need for my diploma thesis and I haven't lot of time. 
Thank you

Outcomes