summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2016-06-16 14:10:05 +0200
committerFelix Fietkau <nbd@nbd.name>2016-06-16 14:27:56 +0200
commit53e2fb59bde914bcded2618d0ce6ce4df267b4a4 (patch)
treee93a8f186e87e66b49211669e2bb3cd4b12a7164
parentf0754619b9ee216b0cb5fc7484f861e876781984 (diff)
downloaduclient-53e2fb59bde914bcded2618d0ce6ce4df267b4a4.tar.gz
http: allow sending message body for DELETE request
Sending entity within DELETE is not forbidden by RFC 7231, see section 4.3.5. DELETE: > A payload within a DELETE request message has no defined semantics; > sending a payload body on a DELETE request might cause some existing > implementations to reject the request. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-rw-r--r--uclient-http.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/uclient-http.c b/uclient-http.c
index c6336a6..f0451cc 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -286,6 +286,18 @@ static void uclient_http_process_headers(struct uclient_http *uh)
uh->auth_type = uclient_http_update_auth_type(uh);
}
+static bool uclient_request_supports_body(enum request_type req_type)
+{
+ switch (req_type) {
+ case REQ_POST:
+ case REQ_PUT:
+ case REQ_DELETE:
+ return true;
+ default:
+ return false;
+ }
+}
+
static void
uclient_http_add_auth_basic(struct uclient_http *uh)
{
@@ -564,7 +576,7 @@ uclient_http_send_headers(struct uclient_http *uh)
blobmsg_for_each_attr(cur, uh->headers.head, rem)
ustream_printf(uh->us, "%s: %s\r\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
- if (uh->req_type == REQ_POST || uh->req_type == REQ_PUT)
+ if (uclient_request_supports_body(uh->req_type))
ustream_printf(uh->us, "Transfer-Encoding: chunked\r\n");
uclient_http_add_auth_header(uh);
@@ -992,7 +1004,7 @@ uclient_http_request_done(struct uclient *cl)
return -1;
uclient_http_send_headers(uh);
- if (uh->req_type == REQ_POST || uh->req_type == REQ_PUT)
+ if (uclient_request_supports_body(uh->req_type))
ustream_printf(uh->us, "0\r\n\r\n");
uh->state = HTTP_STATE_REQUEST_DONE;