maybe in get_http_headers() the line "if (strstr(uri, "404.") == uri)" needs to be changed to "if (strstr(uri, "/404.") == uri)"
Before filing a bug report I ask here because I'm in doubt.
LWIP version is last release got with git clone.
I have prepared a 404.html page with this source code:
<!DOCTYPE html>
<html>
<head>
<title>404 Not Found</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf8">
</head>
<body>
<h1>404 Not Found</h1>
</body>
</html>
In my lwipopts.h I have
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
I generate the fsdata_custom.c file with
makefsdata html -e -f:fsdata_custom.c
(so the headers are not included twice)
What I get when doing a GET of a missing page is wrong (it returns HTTP 200 status code):
If I set LWIP_HTTPD_DYNAMIC_HEADERS to 0 and generate fsdata_custom.c removing the -e switch (makefsdata html -e -f:fsdata_custom.c), the response is correct:
I suppose that the problem is that, with LWIP_HTTPD_DYNAMIC_HEADERS at 1, this piece of code in get_http_headers()
if (strstr(uri, "404.") == uri) {
hs->hdrs[HDR_STRINGS_IDX_HTTP_STATUS] = g_psHTTPHeaderStrings[HTTP_HDR_NOT_FOUND];
}
...does not behave as expected because while debugging I saw that uri equals "/404.html" and not "404.html", so the if condition is not true. I think that changing that line to
if (strstr(uri, "/404.") == uri) {
(and the same for 400 an 501) would be enough; I've tested and it works:
but I'm not sure whether is correct in all possible cases (I mean, all the possible #define combinations supported by LWIP).
Could anyone patient enough to read till here give his opinion? Is my change correct? It's better to file a bug in order to get this corrected?
Cheers
Marco