void __printf(4, 5)
uh_client_error(struct client *cl, int code, const char *summary, const char *fmt, ...)
{
+ struct http_request *r = &cl->request;
va_list arg;
uh_http_header(cl, code, summary);
va_end(arg);
}
+ /* Close the connection even when keep alive is set, when it
+ * contains a request body, as it was not read and we are
+ * currently out of sync. Without handling this the body will be
+ * interpreted as part of the next request. The alternative
+ * would be to read and discard the request body here.
+ */
+ if (r->transfer_chunked || r->content_length > 0) {
+ cl->state = CLIENT_STATE_CLOSE;
+ cl->request.connection_close = true;
+ }
+
uh_request_done(cl);
}
return true;
blob_for_each_attr(cur, cl->hdr.head, rem) {
- if (!strcmp(blobmsg_name(cur), "host"))
+ if (!strncmp(blobmsg_name(cur), "host", 4))
host = blobmsg_get_string(cur);
- if (!strcmp(blobmsg_name(cur), "URL"))
+ if (!strncmp(blobmsg_name(cur), "URL", 3))
url = blobmsg_get_string(cur);
if (url && host)
if (!read_cbs[cl->state](cl, str, len)) {
if (len == us->r.buffer_len &&
- cl->state != CLIENT_STATE_DATA)
+ cl->state != CLIENT_STATE_DATA &&
+ cl->state != CLIENT_STATE_DONE)
uh_header_error(cl, 413, "Request Entity Too Large");
break;
}