Report missing Content-Disposition header

This commit is contained in:
Andrew Bettison 2016-02-22 18:14:53 +10:30
parent 463e27684c
commit 518740bcf2
4 changed files with 17 additions and 2 deletions

11
httpd.c
View File

@ -485,9 +485,16 @@ int http_response_content_type(httpd_request *r, uint16_t result, const char *wh
int http_response_content_disposition(httpd_request *r, uint16_t result, const char *what, const char *type)
{
DEBUGF(httpd, "%s Content-Disposition: %s %s", what, type);
DEBUGF(httpd, "%s Content-Disposition%s%s", what,
type && type[0] ? ": " : "",
type && type[0] ? type : " header"
);
strbuf msg = strbuf_alloca(100);
strbuf_sprintf(msg, "%s Content-Disposition: %s", what, type);
strbuf_sprintf(msg, "%s Content-Disposition", what);
if (type && type[0])
strbuf_sprintf(msg, ": %s", type);
else
strbuf_puts(msg, " header");
http_request_simple_response(&r->http, result, strbuf_str(msg)); // Unsupported Media Type
return result;
}

View File

@ -609,6 +609,8 @@ static int send_mime_part_end(struct http_request *hr)
static int send_mime_part_header(struct http_request *hr, const struct mime_part_headers *h)
{
httpd_request *r = (httpd_request *) hr;
if (!h->content_disposition.type[0])
return http_response_content_disposition(r, 415, "Missing", h->content_disposition.type);
if (strcmp(h->content_disposition.type, "form-data") != 0)
return http_response_content_disposition(r, 415, "Unsupported", h->content_disposition.type);
if (strcmp(h->content_disposition.name, PART_MESSAGE) == 0) {

View File

@ -309,6 +309,10 @@ static int rhizome_direct_process_mime_end(struct http_request *hr)
static int rhizome_direct_process_mime_part_header(struct http_request *hr, const struct mime_part_headers *h)
{
httpd_request *r = (httpd_request *) hr;
if (!h->content_disposition.type[0])
return http_response_content_disposition(r, 415, "Missing", h->content_disposition.type);
if (strcmp(h->content_disposition.type, "form-data") != 0)
return http_response_content_disposition(r, 415, "Unsupported", h->content_disposition.type);
if ( strcmp(h->content_disposition.name, PART_PAYLOAD) == 0
|| strcmp(h->content_disposition.name, PART_DATA) == 0
) {

View File

@ -470,6 +470,8 @@ static int insert_make_manifest(httpd_request *r)
static int insert_mime_part_header(struct http_request *hr, const struct mime_part_headers *h)
{
httpd_request *r = (httpd_request *) hr;
if (!h->content_disposition.type[0])
return http_response_content_disposition(r, 415, "Missing", h->content_disposition.type);
if (strcmp(h->content_disposition.type, "form-data") != 0)
return http_response_content_disposition(r, 415, "Unsupported", h->content_disposition.type);
if (strcmp(h->content_disposition.name, PART_AUTHOR) == 0) {