diff --git a/httpd.c b/httpd.c index 5b4c80f4..5f341844 100644 --- a/httpd.c +++ b/httpd.c @@ -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; } diff --git a/meshms_restful.c b/meshms_restful.c index 25486757..7cce839a 100644 --- a/meshms_restful.c +++ b/meshms_restful.c @@ -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) { diff --git a/rhizome_direct_http.c b/rhizome_direct_http.c index 5db64439..08dcaaee 100644 --- a/rhizome_direct_http.c +++ b/rhizome_direct_http.c @@ -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 ) { diff --git a/rhizome_restful.c b/rhizome_restful.c index 78c1c130..805c34ef 100644 --- a/rhizome_restful.c +++ b/rhizome_restful.c @@ -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) {