diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 2ef0b989..c63b8d24 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -1268,11 +1268,11 @@ build_header_response (struct MHD_Connection *connection) | |||
1268 | bool response_has_close; | 1268 | bool response_has_close; |
1269 | bool response_has_keepalive; | 1269 | bool response_has_keepalive; |
1270 | const char *have_encoding; | 1270 | const char *have_encoding; |
1271 | int must_add_close; | 1271 | bool must_add_close; |
1272 | int must_add_chunked_encoding; | 1272 | bool must_add_chunked_encoding; |
1273 | int must_add_keep_alive; | 1273 | bool must_add_keep_alive; |
1274 | int must_add_content_length; | 1274 | bool must_add_content_length; |
1275 | int may_add_content_length; | 1275 | bool may_add_content_length; |
1276 | 1276 | ||
1277 | mhd_assert (NULL != connection->version); | 1277 | mhd_assert (NULL != connection->version); |
1278 | if (0 == connection->version[0]) | 1278 | if (0 == connection->version[0]) |
@@ -1328,10 +1328,10 @@ build_header_response (struct MHD_Connection *connection) | |||
1328 | 1328 | ||
1329 | /* calculate extra headers we need to add, such as 'Connection: close', | 1329 | /* calculate extra headers we need to add, such as 'Connection: close', |
1330 | first see what was explicitly requested by the application */ | 1330 | first see what was explicitly requested by the application */ |
1331 | must_add_close = MHD_NO; | 1331 | must_add_close = false; |
1332 | must_add_chunked_encoding = MHD_NO; | 1332 | must_add_chunked_encoding = false; |
1333 | must_add_keep_alive = MHD_NO; | 1333 | must_add_keep_alive = false; |
1334 | must_add_content_length = MHD_NO; | 1334 | must_add_content_length = false; |
1335 | response_has_close = false; | 1335 | response_has_close = false; |
1336 | switch (connection->state) | 1336 | switch (connection->state) |
1337 | { | 1337 | { |
@@ -1359,9 +1359,9 @@ build_header_response (struct MHD_Connection *connection) | |||
1359 | have_encoding = MHD_get_response_header (response, | 1359 | have_encoding = MHD_get_response_header (response, |
1360 | MHD_HTTP_HEADER_TRANSFER_ENCODING); | 1360 | MHD_HTTP_HEADER_TRANSFER_ENCODING); |
1361 | if (NULL == have_encoding) | 1361 | if (NULL == have_encoding) |
1362 | may_add_content_length = MHD_YES; | 1362 | may_add_content_length = true; |
1363 | else | 1363 | else |
1364 | may_add_content_length = MHD_NO; /* RFC 7230, Section 3.3.2 forbids header */ | 1364 | may_add_content_length = false; /* RFC 7230, Section 3.3.2 forbids header */ |
1365 | if ( (MHD_SIZE_UNKNOWN == response->total_size) && | 1365 | if ( (MHD_SIZE_UNKNOWN == response->total_size) && |
1366 | #ifdef UPGRADE_SUPPORT | 1366 | #ifdef UPGRADE_SUPPORT |
1367 | (NULL == response->upgrade_handler) && | 1367 | (NULL == response->upgrade_handler) && |
@@ -1380,7 +1380,7 @@ build_header_response (struct MHD_Connection *connection) | |||
1380 | { | 1380 | { |
1381 | if (NULL == have_encoding) | 1381 | if (NULL == have_encoding) |
1382 | { | 1382 | { |
1383 | must_add_chunked_encoding = MHD_YES; | 1383 | must_add_chunked_encoding = true; |
1384 | connection->have_chunked_upload = true; | 1384 | connection->have_chunked_upload = true; |
1385 | } | 1385 | } |
1386 | else | 1386 | else |
@@ -1389,7 +1389,7 @@ build_header_response (struct MHD_Connection *connection) | |||
1389 | "identity")) | 1389 | "identity")) |
1390 | { | 1390 | { |
1391 | /* application forced identity encoding, can't do 'chunked' */ | 1391 | /* application forced identity encoding, can't do 'chunked' */ |
1392 | must_add_close = MHD_YES; | 1392 | must_add_close = true; |
1393 | } | 1393 | } |
1394 | else | 1394 | else |
1395 | { | 1395 | { |
@@ -1402,7 +1402,7 @@ build_header_response (struct MHD_Connection *connection) | |||
1402 | /* Keep alive or chunking not possible | 1402 | /* Keep alive or chunking not possible |
1403 | => set close header if not present */ | 1403 | => set close header if not present */ |
1404 | if (! response_has_close) | 1404 | if (! response_has_close) |
1405 | must_add_close = MHD_YES; | 1405 | must_add_close = true; |
1406 | } | 1406 | } |
1407 | } | 1407 | } |
1408 | 1408 | ||
@@ -1415,14 +1415,14 @@ build_header_response (struct MHD_Connection *connection) | |||
1415 | (NULL == response->upgrade_handler) && | 1415 | (NULL == response->upgrade_handler) && |
1416 | #endif /* UPGRADE_SUPPORT */ | 1416 | #endif /* UPGRADE_SUPPORT */ |
1417 | (0 == (response->flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) ) | 1417 | (0 == (response->flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) ) |
1418 | must_add_close = MHD_YES; | 1418 | must_add_close = true; |
1419 | 1419 | ||
1420 | /* check if we must add 'close' header because we cannot add content-length | 1420 | /* check if we must add 'close' header because we cannot add content-length |
1421 | because it is forbidden AND we don't have a 'chunked' encoding */ | 1421 | because it is forbidden AND we don't have a 'chunked' encoding */ |
1422 | if ( (! may_add_content_length) && | 1422 | if ( (! may_add_content_length) && |
1423 | (! connection->have_chunked_upload) && | 1423 | (! connection->have_chunked_upload) && |
1424 | (! response_has_close) ) | 1424 | (! response_has_close) ) |
1425 | must_add_close = MHD_YES; | 1425 | must_add_close = true; |
1426 | /* #MHD_HTTP_NO_CONTENT, #MHD_HTTP_NOT_MODIFIED and 1xx-status | 1426 | /* #MHD_HTTP_NO_CONTENT, #MHD_HTTP_NOT_MODIFIED and 1xx-status |
1427 | codes SHOULD NOT have a Content-Length according to spec; | 1427 | codes SHOULD NOT have a Content-Length according to spec; |
1428 | also chunked encoding / unknown length or CONNECT... */ | 1428 | also chunked encoding / unknown length or CONNECT... */ |
@@ -1461,19 +1461,19 @@ build_header_response (struct MHD_Connection *connection) | |||
1461 | MHD_HTTP_HEADER_CONTENT_LENGTH ": " | 1461 | MHD_HTTP_HEADER_CONTENT_LENGTH ": " |
1462 | MHD_UNSIGNED_LONG_LONG_PRINTF "\r\n", | 1462 | MHD_UNSIGNED_LONG_LONG_PRINTF "\r\n", |
1463 | (MHD_UNSIGNED_LONG_LONG) response->total_size); | 1463 | (MHD_UNSIGNED_LONG_LONG) response->total_size); |
1464 | must_add_content_length = MHD_YES; | 1464 | must_add_content_length = true; |
1465 | } | 1465 | } |
1466 | 1466 | ||
1467 | /* check for adding keep alive */ | 1467 | /* check for adding keep alive */ |
1468 | if ( (! response_has_keepalive) && | 1468 | if ( (! response_has_keepalive) && |
1469 | (! response_has_close) && | 1469 | (! response_has_close) && |
1470 | (MHD_NO == must_add_close) && | 1470 | (! must_add_close) && |
1471 | (MHD_CONN_MUST_CLOSE != connection->keepalive) && | 1471 | (MHD_CONN_MUST_CLOSE != connection->keepalive) && |
1472 | #ifdef UPGRADE_SUPPORT | 1472 | #ifdef UPGRADE_SUPPORT |
1473 | (NULL == response->upgrade_handler) && | 1473 | (NULL == response->upgrade_handler) && |
1474 | #endif /* UPGRADE_SUPPORT */ | 1474 | #endif /* UPGRADE_SUPPORT */ |
1475 | (MHD_YES == keepalive_possible (connection)) ) | 1475 | (MHD_YES == keepalive_possible (connection)) ) |
1476 | must_add_keep_alive = MHD_YES; | 1476 | must_add_keep_alive = true; |
1477 | break; | 1477 | break; |
1478 | case MHD_CONNECTION_BODY_SENT: | 1478 | case MHD_CONNECTION_BODY_SENT: |
1479 | response_has_keepalive = false; | 1479 | response_has_keepalive = false; |
@@ -1506,7 +1506,7 @@ build_header_response (struct MHD_Connection *connection) | |||
1506 | { | 1506 | { |
1507 | /* TODO: add proper support for excluding "Keep-Alive" token. */ | 1507 | /* TODO: add proper support for excluding "Keep-Alive" token. */ |
1508 | if ( (pos->kind == kind) && | 1508 | if ( (pos->kind == kind) && |
1509 | (! ( (MHD_YES == must_add_close) && | 1509 | (! ( (must_add_close) && |
1510 | (response_has_keepalive) && | 1510 | (response_has_keepalive) && |
1511 | (pos->header_size == MHD_STATICSTR_LEN_ ( | 1511 | (pos->header_size == MHD_STATICSTR_LEN_ ( |
1512 | MHD_HTTP_HEADER_CONNECTION)) && | 1512 | MHD_HTTP_HEADER_CONNECTION)) && |
@@ -1572,7 +1572,7 @@ build_header_response (struct MHD_Connection *connection) | |||
1572 | { | 1572 | { |
1573 | /* TODO: add proper support for excluding "Keep-Alive" token. */ | 1573 | /* TODO: add proper support for excluding "Keep-Alive" token. */ |
1574 | if ( (pos->kind == kind) && | 1574 | if ( (pos->kind == kind) && |
1575 | (! ( (MHD_YES == must_add_close) && | 1575 | (! ( (must_add_close) && |
1576 | (response_has_keepalive) && | 1576 | (response_has_keepalive) && |
1577 | (pos->header_size == MHD_STATICSTR_LEN_ ( | 1577 | (pos->header_size == MHD_STATICSTR_LEN_ ( |
1578 | MHD_HTTP_HEADER_CONNECTION)) && | 1578 | MHD_HTTP_HEADER_CONNECTION)) && |