mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-05 12:29:38 +00:00
lookup content type only when needed
This commit is contained in:
parent
a95c2cf6c1
commit
0d6dabe6f5
@ -103,16 +103,11 @@ PT_THREAD(send_string(struct httpd_state *s, const char *str))
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
static const char *
|
||||
get_content_type(const char *filename)
|
||||
{
|
||||
static const char *ptr;
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
const char *ptr;
|
||||
ptr = strrchr(filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
ptr = http_content_type_plain;
|
||||
} else if(strcmp(http_htm, ptr) == 0) {
|
||||
@ -128,7 +123,17 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
} else {
|
||||
ptr = http_content_type_binary;
|
||||
}
|
||||
SEND_STRING(&s->sout, ptr);
|
||||
return ptr;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
SEND_STRING(&s->sout, get_content_type(s->filename));
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -103,16 +103,11 @@ PT_THREAD(send_string(struct httpd_state *s, const char *str))
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
static const char *
|
||||
get_content_type(const char *filename)
|
||||
{
|
||||
static const char *ptr;
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
const char *ptr;
|
||||
ptr = strrchr(filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
ptr = http_content_type_plain;
|
||||
} else if(strcmp(http_htm, ptr) == 0) {
|
||||
@ -128,7 +123,17 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
} else {
|
||||
ptr = http_content_type_binary;
|
||||
}
|
||||
SEND_STRING(&s->sout, ptr);
|
||||
return ptr;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
SEND_STRING(&s->sout, get_content_type(s->filename));
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user