mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 12:39:01 -04:00
allow us to pass content-type to http_response()
This commit is contained in:
parent
a39040ba9b
commit
4ecfd81e6e
@ -8,5 +8,5 @@ load ../betrippin/betrippin.module
|
||||
|
||||
# Declare page handlers below.
|
||||
# handler path module_callback
|
||||
static /css/style.css betrippin_serve_style_css
|
||||
static /css/main.css betrippin_serve_style_css
|
||||
static / betrippin_serve_index
|
||||
|
@ -32,7 +32,7 @@ void http_init(void);
|
||||
void http_process(void);
|
||||
void http_request_free(struct http_request *);
|
||||
int http_response(struct http_request *, int,
|
||||
u_int8_t *, u_int32_t);
|
||||
u_int8_t *, u_int32_t, char *);
|
||||
int http_new_request(struct connection *, struct spdy_stream *,
|
||||
char *, char *, char *);
|
||||
|
||||
|
10
src/http.c
10
src/http.c
@ -77,7 +77,8 @@ http_request_free(struct http_request *req)
|
||||
}
|
||||
|
||||
int
|
||||
http_response(struct http_request *req, int status, u_int8_t *d, u_int32_t len)
|
||||
http_response(struct http_request *req, int status, u_int8_t *d,
|
||||
u_int32_t len, char *content_type)
|
||||
{
|
||||
u_int32_t hlen;
|
||||
u_int8_t *htext;
|
||||
@ -91,7 +92,10 @@ http_response(struct http_request *req, int status, u_int8_t *d, u_int32_t len)
|
||||
hblock = spdy_header_block_create(SPDY_HBLOCK_NORMAL);
|
||||
spdy_header_block_add(hblock, ":status", sbuf);
|
||||
spdy_header_block_add(hblock, ":version", "HTTP/1.1");
|
||||
spdy_header_block_add(hblock, "content-type", "text/plain");
|
||||
if (content_type != NULL) {
|
||||
spdy_header_block_add(hblock,
|
||||
"content-type", content_type);
|
||||
}
|
||||
htext = spdy_header_block_release(req->owner, hblock, &hlen);
|
||||
if (htext == NULL)
|
||||
return (KORE_RESULT_ERROR);
|
||||
@ -155,5 +159,5 @@ http_generic_404(struct http_request *req)
|
||||
kore_log("http_generic_404(%s, %s, %s)",
|
||||
req->host, req->method, req->path);
|
||||
|
||||
return (http_response(req, 404, NULL, 0));
|
||||
return (http_response(req, 404, NULL, 0, NULL));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user