Skip to content

Commit b914192

Browse files
committed
fix #2997
1 parent ed79fe8 commit b914192

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

test/unit_test.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ static void test_http_no_content_length(void) {
14691469
char buf[100];
14701470
struct mg_mgr mgr;
14711471
const char *url = "http://127.0.0.1:12348";
1472+
const char *url2 = "http://127.0.0.1:12349";
14721473
int i;
14731474
const char *post_req =
14741475
"POST / HTTP/1.1\r\nContent-Type:"
@@ -1482,17 +1483,17 @@ static void test_http_no_content_length(void) {
14821483
ASSERT(strcmp(buf1, "mc") == 0);
14831484
ASSERT(strcmp(buf2, "mc") == 0);
14841485
mg_mgr_free(&mgr);
1485-
1486+
// 12348 is in TIME_WAIT, use another port
14861487
mg_mgr_init(&mgr);
1487-
mg_http_listen(&mgr, url, f41, (void *) NULL);
1488-
ASSERT(fetch(&mgr, buf, url, "POST / HTTP/1.1\r\n\r\n") == 411);
1489-
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 200\r\n\r\n") == 411);
1490-
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 100\r\n\r\n") != 411);
1491-
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 304\r\n\r\n") != 411);
1492-
ASSERT(fetch(&mgr, buf, url, "HTTP/1.1 305\r\n\r\n") == 411);
1493-
ASSERT(fetch(&mgr, buf, url, post_req) != 411);
1488+
mg_http_listen(&mgr, url2, f41, (void *) NULL);
1489+
ASSERT(fetch(&mgr, buf, url2, "POST / HTTP/1.1\r\n\r\n") == 411);
1490+
ASSERT(fetch(&mgr, buf, url2, "HTTP/1.1 200\r\n\r\n") == 411);
1491+
ASSERT(fetch(&mgr, buf, url2, "HTTP/1.1 100\r\n\r\n") != 411);
1492+
ASSERT(fetch(&mgr, buf, url2, "HTTP/1.1 304\r\n\r\n") != 411);
1493+
ASSERT(fetch(&mgr, buf, url2, "HTTP/1.1 305\r\n\r\n") == 411);
1494+
ASSERT(fetch(&mgr, buf, url2, post_req) != 411);
14941495
// Check it is processed only once (see #2811)
1495-
ASSERT(fpr(&mgr, buf, url, "POST / HTTP/1.1\r\n\r\n") == 411);
1496+
ASSERT(fpr(&mgr, buf, url2, "POST / HTTP/1.1\r\n\r\n") == 411);
14961497
mg_mgr_free(&mgr);
14971498
ASSERT(mgr.conns == NULL);
14981499
}
@@ -1772,7 +1773,7 @@ static void ehr(struct mg_connection *c, int ev, void *ev_data) {
17721773

17731774
static void test_http_range(void) {
17741775
struct mg_mgr mgr;
1775-
const char *url = "http://127.0.0.1:12349";
1776+
const char *url = "http://127.0.0.1:12350";
17761777
struct mg_http_message hm;
17771778
char buf[FETCH_BUF_SIZE];
17781779

0 commit comments

Comments
 (0)