Merge pull request #2971 from cesanta/411

Fix issuing 411 responses as a client
This commit is contained in:
Sergio R. Caprile 2024-11-22 16:37:19 -03:00 committed by GitHub
commit 8ef02aae41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -2417,8 +2417,8 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
require_content_len = status >= 200 && status != 204 && status != 304;
}
if (require_content_len) {
mg_http_reply(c, 411, "", "");
MG_ERROR(("%s", "Content length missing from request"));
if (!c->is_client) mg_http_reply(c, 411, "", "");
MG_ERROR(("Content length missing from %s", is_response ? "response" : "request"));
}
}

View File

@ -1059,8 +1059,8 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) {
require_content_len = status >= 200 && status != 204 && status != 304;
}
if (require_content_len) {
mg_http_reply(c, 411, "", "");
MG_ERROR(("%s", "Content length missing from request"));
if (!c->is_client) mg_http_reply(c, 411, "", "");
MG_ERROR(("Content length missing from %s", is_response ? "response" : "request"));
}
}