Made cfs-based webserver example compatible with 8.3 file systems.
This commit is contained in:
parent
8631ae8515
commit
cd24e920b6
9 changed files with 38 additions and 33 deletions
|
@ -10,6 +10,7 @@ http_texthtml "text/html"
|
|||
http_location "location: "
|
||||
http_host "host: "
|
||||
http_crnl "\r\n"
|
||||
http_index_htm "/index.htm"
|
||||
http_index_html "/index.html"
|
||||
http_404_html "/404.html"
|
||||
http_referer "Referer:"
|
||||
|
|
|
@ -34,6 +34,9 @@ const char http_host[7] =
|
|||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_htm[11] =
|
||||
/* "/index.htm" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
|
|
|
@ -10,6 +10,7 @@ extern const char http_texthtml[10];
|
|||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_htm[11];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-cfs.c,v 1.23 2010/08/30 19:44:38 oliverschmidt Exp $
|
||||
* $Id: httpd-cfs.c,v 1.24 2010/09/28 20:40:52 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -141,7 +141,7 @@ PT_THREAD(handle_output(struct httpd_state *s))
|
|||
s->fd = cfs_open(&s->filename[1], CFS_READ);
|
||||
petsciiconv_toascii(s->filename, sizeof(s->filename));
|
||||
if(s->fd < 0) {
|
||||
strcpy(s->filename, "/notfound.html");
|
||||
strcpy(s->filename, "/notfound.htm");
|
||||
s->fd = cfs_open(&s->filename[1], CFS_READ);
|
||||
petsciiconv_toascii(s->filename, sizeof(s->filename));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
|
@ -150,10 +150,10 @@ PT_THREAD(handle_output(struct httpd_state *s))
|
|||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_string(s, "not found"));
|
||||
uip_close();
|
||||
webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.html)");
|
||||
webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.htm)");
|
||||
PT_EXIT(&s->outputpt);
|
||||
}
|
||||
webserver_log_file(&uip_conn->ripaddr, "404 - notfound.html");
|
||||
webserver_log_file(&uip_conn->ripaddr, "404 - notfound.htm");
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_200));
|
||||
|
@ -186,7 +186,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
|
|||
urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
#else /* URLCONV */
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
strncpy(s->filename, http_index_htm, sizeof(s->filename));
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Kajtar Zsolt <soci@c64.rulez.org>
|
||||
*
|
||||
* $Id: urlconv.c,v 1.2 2010/08/30 19:44:38 oliverschmidt Exp $
|
||||
* $Id: urlconv.c,v 1.3 2010/09/28 20:40:52 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
@ -140,7 +140,7 @@ urlconv_tofilename(char *dest, char *source, unsigned char maxlen)
|
|||
}
|
||||
} while(c);
|
||||
if(*to == ISO_slash && (len + sizeof(http_index_html) - 3) < maxlen) {
|
||||
strcpy(to, http_index_html); // add index.html
|
||||
strcpy(to, http_index_htm); // add index.htm
|
||||
} else {
|
||||
++to;
|
||||
*to = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue