mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
mg_read() with no Content-Length would read until socket is closed
This commit is contained in:
1 parent
a856971b6d
commit
e7c34c26cb
2 files changed
+25
-3
No files matched your search
+12
-2
@@ -220,9 +220,9 @@ static int begin_request_handler_cb(struct mg_connection *conn) {
|
||||
|
||||
if (!strcmp(ri->uri, "/data")) {
|
||||
mg_printf(conn, "HTTP/1.1 200 OK\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"Content-Type: text/plain\r\n\r\n"
|
||||
"%s", (int) strlen(fetch_data), fetch_data);
|
||||
"%s", fetch_data);
|
||||
close_connection(conn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -298,6 +298,7 @@ static void test_mg_download(void) {
|
||||
free(p1), free(p2);
|
||||
mg_close_connection(conn);
|
||||
|
||||
|
||||
// Fetch in-memory file, should succeed.
|
||||
ASSERT((conn = mg_download("localhost", port, 1, ebuf, sizeof(ebuf), "%s",
|
||||
"GET /blah HTTP/1.1\r\n\r\n")) != NULL);
|
||||
@@ -307,6 +308,15 @@ static void test_mg_download(void) {
|
||||
free(p1);
|
||||
mg_close_connection(conn);
|
||||
|
||||
// Fetch in-memory data with no Content-Length, should succeed.
|
||||
ASSERT((conn = mg_download("localhost", port, 1, ebuf, sizeof(ebuf), "%s",
|
||||
"GET /data HTTP/1.1\r\n\r\n")) != NULL);
|
||||
ASSERT((p1 = read_conn(conn, &len1)) != NULL);
|
||||
ASSERT(len1 == (int) strlen(fetch_data));
|
||||
ASSERT(memcmp(p1, fetch_data, len1) == 0);
|
||||
free(p1);
|
||||
mg_close_connection(conn);
|
||||
|
||||
// Test SSL redirect, IP address
|
||||
ASSERT((conn = mg_download("localhost", atoi(HTTP_PORT), 0,
|
||||
ebuf, sizeof(ebuf), "%s",
|
||||
|
||||
Reference in new issue
Block a user