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);
|
PSOCK_END(&s->sout);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static
|
static const char *
|
||||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
get_content_type(const char *filename)
|
||||||
{
|
{
|
||||||
static const char *ptr;
|
const char *ptr;
|
||||||
|
ptr = strrchr(filename, ISO_period);
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
SEND_STRING(&s->sout, statushdr);
|
|
||||||
|
|
||||||
ptr = strrchr(s->filename, ISO_period);
|
|
||||||
if(ptr == NULL) {
|
if(ptr == NULL) {
|
||||||
ptr = http_content_type_plain;
|
ptr = http_content_type_plain;
|
||||||
} else if(strcmp(http_htm, ptr) == 0) {
|
} else if(strcmp(http_htm, ptr) == 0) {
|
||||||
@ -128,7 +123,17 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
|||||||
} else {
|
} else {
|
||||||
ptr = http_content_type_binary;
|
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);
|
PSOCK_END(&s->sout);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -103,16 +103,11 @@ PT_THREAD(send_string(struct httpd_state *s, const char *str))
|
|||||||
PSOCK_END(&s->sout);
|
PSOCK_END(&s->sout);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static
|
static const char *
|
||||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
get_content_type(const char *filename)
|
||||||
{
|
{
|
||||||
static const char *ptr;
|
const char *ptr;
|
||||||
|
ptr = strrchr(filename, ISO_period);
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
SEND_STRING(&s->sout, statushdr);
|
|
||||||
|
|
||||||
ptr = strrchr(s->filename, ISO_period);
|
|
||||||
if(ptr == NULL) {
|
if(ptr == NULL) {
|
||||||
ptr = http_content_type_plain;
|
ptr = http_content_type_plain;
|
||||||
} else if(strcmp(http_htm, ptr) == 0) {
|
} else if(strcmp(http_htm, ptr) == 0) {
|
||||||
@ -128,7 +123,17 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
|||||||
} else {
|
} else {
|
||||||
ptr = http_content_type_binary;
|
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);
|
PSOCK_END(&s->sout);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user