Skip to main content
zavodny
Associate II
April 2, 2014
Question

Parse HTTP header

  • April 2, 2014
  • 2 replies
  • 804 views
Posted on April 02, 2014 at 21:06

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
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    April 2, 2014
    Posted on April 02, 2014 at 21:38

    I don't know why?

    Make it stand-alone, grab half a dozen test cases, encode these in your test framework, and build it on a PC based compiler/tool-chain so you can instrument it, and debug it.
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    April 3, 2014
    Posted on April 03, 2014 at 09:15

    This is not an STM32-specific question, thus better be asked on an lwip-related forum, such as https://lists.nongnu.org/mailman/listinfo/lwip-users .

    > Sometimes parsed data isn't correct.

    You should start with being more specific with this - what are then inputs to the function, what are the parsed outputs and how do the results fail short of your expectations.

    JW