| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 /* | 4 /* |
| 5 * pkix_pl_httpdefaultclient.c | 5 * pkix_pl_httpdefaultclient.c |
| 6 * | 6 * |
| 7 * HTTPDefaultClient Function Definitions | 7 * HTTPDefaultClient Function Definitions |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 *pKeepGoing = PKIX_FALSE; | 258 *pKeepGoing = PKIX_FALSE; |
| 259 break; | 259 break; |
| 260 | 260 |
| 261 case HTTP_UNKNOWN_CONTENT_LENGTH: | 261 case HTTP_UNKNOWN_CONTENT_LENGTH: |
| 262 /* Unknown contentLength indicator.Will be set by | 262 /* Unknown contentLength indicator.Will be set by |
| 263 * pkix_pl_HttpDefaultClient_RecvBody whey connection get closed */ | 263 * pkix_pl_HttpDefaultClient_RecvBody whey connection get closed */ |
| 264 client->rcv_http_data_len = HTTP_UNKNOWN_CONTENT_LENGTH; | 264 client->rcv_http_data_len = HTTP_UNKNOWN_CONTENT_LENGTH; |
| 265 contentLength = /* Try to reserve 4K+ buffer */ | 265 contentLength = /* Try to reserve 4K+ buffer */ |
| 266 client->filledupBytes + HTTP_DATA_BUFSIZE; | 266 client->filledupBytes + HTTP_DATA_BUFSIZE; |
| 267 if (client->maxResponseLen > 0 && | 267 if (client->maxResponseLen > 0 && |
| 268 contentLength > client->maxResponseLen) { | 268 contentLength > (PKIX_Int32)client->maxResponseLen) { |
| 269 if (client->filledupBytes < client->maxResponseLen) { | 269 if (client->filledupBytes < client->maxResponseLen) { |
| 270 contentLength = client->maxResponseLen; | 270 contentLength = client->maxResponseLen; |
| 271 } else { | 271 } else { |
| 272 client->connectStatus = HTTP_ERROR; | 272 client->connectStatus = HTTP_ERROR; |
| 273 goto cleanup; | 273 goto cleanup; |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 /* set available number of bytes in the buffer */ | 276 /* set available number of bytes in the buffer */ |
| 277 client->capacity = contentLength; | 277 client->capacity = contentLength; |
| 278 client->connectStatus = HTTP_RECV_BODY; | 278 client->connectStatus = HTTP_RECV_BODY; |
| 279 *pKeepGoing = PKIX_TRUE; | 279 *pKeepGoing = PKIX_TRUE; |
| 280 break; | 280 break; |
| 281 | 281 |
| 282 default: | 282 default: |
| 283 client->rcv_http_data_len = contentLength; | 283 client->rcv_http_data_len = contentLength; |
| 284 if (client->maxResponseLen > 0 && | 284 if (client->maxResponseLen > 0 && |
| 285 client->maxResponseLen < contentLength) { | 285 (PKIX_Int32)client->maxResponseLen < contentLength) { |
| 286 client->connectStatus = HTTP_ERROR; | 286 client->connectStatus = HTTP_ERROR; |
| 287 goto cleanup; | 287 goto cleanup; |
| 288 } | 288 } |
| 289 | 289 |
| 290 /* | 290 /* |
| 291 * Do we have all of the message body, or do we need to read some m
ore? | 291 * Do we have all of the message body, or do we need to read some m
ore? |
| 292 */ | 292 */ |
| 293 if (client->filledupBytes < contentLength) { | 293 if ((PKIX_Int32)client->filledupBytes < contentLength) { |
| 294 client->connectStatus = HTTP_RECV_BODY; | 294 client->connectStatus = HTTP_RECV_BODY; |
| 295 *pKeepGoing = PKIX_TRUE; | 295 *pKeepGoing = PKIX_TRUE; |
| 296 } else { | 296 } else { |
| 297 client->connectStatus = HTTP_COMPLETE; | 297 client->connectStatus = HTTP_COMPLETE; |
| 298 *pKeepGoing = PKIX_FALSE; | 298 *pKeepGoing = PKIX_FALSE; |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 if (contentLength > 0) { | 302 if (contentLength > 0) { |
| 303 /* allocate a buffer of size contentLength for the content */ | 303 /* allocate a buffer of size contentLength for the content */ |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } else { | 928 } else { |
| 929 /* Reading till the EOF. Context length is not known.*/ | 929 /* Reading till the EOF. Context length is not known.*/ |
| 930 /* Check the buffer capacity: increase and | 930 /* Check the buffer capacity: increase and |
| 931 * reallocate if it is low. */ | 931 * reallocate if it is low. */ |
| 932 int freeBuffSize = client->capacity - client->filledupBytes; | 932 int freeBuffSize = client->capacity - client->filledupBytes; |
| 933 if (freeBuffSize < HTTP_MIN_AVAILABLE_BUFFER_SIZE) { | 933 if (freeBuffSize < HTTP_MIN_AVAILABLE_BUFFER_SIZE) { |
| 934 /* New length will be consist of available(downloaded) bytes, | 934 /* New length will be consist of available(downloaded) bytes, |
| 935 * plus remaining capacity, plus new expansion. */ | 935 * plus remaining capacity, plus new expansion. */ |
| 936 int currBuffSize = client->capacity; | 936 int currBuffSize = client->capacity; |
| 937 /* Try to increase the buffer by 4K */ | 937 /* Try to increase the buffer by 4K */ |
| 938 int newLength = currBuffSize + HTTP_DATA_BUFSIZE; | 938 unsigned int newLength = currBuffSize + HTTP_DATA_BUFSIZE; |
| 939 if (client->maxResponseLen > 0 && | 939 if (client->maxResponseLen > 0 && |
| 940 newLength > client->maxResponseLen) { | 940 newLength > client->maxResponseLen) { |
| 941 newLength = client->maxResponseLen; | 941 newLength = client->maxResponseLen; |
| 942 } | 942 } |
| 943 /* Check if we can grow the buffer and report an error if | 943 /* Check if we can grow the buffer and report an error if |
| 944 * new size is not larger than the current size of the buffer.*/ | 944 * new size is not larger than the current size of the buffer.*/ |
| 945 if (newLength <= client->filledupBytes) { | 945 if (newLength <= client->filledupBytes) { |
| 946 client->rcv_http_data_len = client->filledupBytes; | 946 client->rcv_http_data_len = client->filledupBytes; |
| 947 client->connectStatus = HTTP_ERROR; | 947 client->connectStatus = HTTP_ERROR; |
| 948 *pKeepGoing = PKIX_FALSE; | 948 *pKeepGoing = PKIX_FALSE; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 | 1473 |
| 1474 PKIX_RETURN(HTTPDEFAULTCLIENT); | 1474 PKIX_RETURN(HTTPDEFAULTCLIENT); |
| 1475 | 1475 |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 PKIX_Error * | 1478 PKIX_Error * |
| 1479 pkix_pl_HttpDefaultClient_Cancel( | 1479 pkix_pl_HttpDefaultClient_Cancel( |
| 1480 SEC_HTTP_REQUEST_SESSION request, | 1480 SEC_HTTP_REQUEST_SESSION request, |
| 1481 void *plContext) | 1481 void *plContext) |
| 1482 { | 1482 { |
| 1483 PKIX_PL_HttpDefaultClient *client = NULL; | |
| 1484 | |
| 1485 PKIX_ENTER(HTTPDEFAULTCLIENT, "pkix_pl_HttpDefaultClient_Cancel"); | 1483 PKIX_ENTER(HTTPDEFAULTCLIENT, "pkix_pl_HttpDefaultClient_Cancel"); |
| 1486 PKIX_NULLCHECK_ONE(request); | 1484 PKIX_NULLCHECK_ONE(request); |
| 1487 | 1485 |
| 1488 PKIX_CHECK(pkix_CheckType | 1486 PKIX_CHECK(pkix_CheckType |
| 1489 ((PKIX_PL_Object *)request, | 1487 ((PKIX_PL_Object *)request, |
| 1490 PKIX_HTTPDEFAULTCLIENT_TYPE, | 1488 PKIX_HTTPDEFAULTCLIENT_TYPE, |
| 1491 plContext), | 1489 plContext), |
| 1492 PKIX_REQUESTNOTANHTTPDEFAULTCLIENT); | 1490 PKIX_REQUESTNOTANHTTPDEFAULTCLIENT); |
| 1493 | 1491 |
| 1494 client = (PKIX_PL_HttpDefaultClient *)request; | |
| 1495 | |
| 1496 /* XXX Not implemented */ | 1492 /* XXX Not implemented */ |
| 1497 | 1493 |
| 1498 cleanup: | 1494 cleanup: |
| 1499 | 1495 |
| 1500 PKIX_RETURN(HTTPDEFAULTCLIENT); | 1496 PKIX_RETURN(HTTPDEFAULTCLIENT); |
| 1501 | 1497 |
| 1502 } | 1498 } |
| 1503 | 1499 |
| 1504 SECStatus | 1500 SECStatus |
| 1505 pkix_pl_HttpDefaultClient_CreateSessionFcn( | 1501 pkix_pl_HttpDefaultClient_CreateSessionFcn( |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 { | 1645 { |
| 1650 PKIX_Error *err = | 1646 PKIX_Error *err = |
| 1651 PKIX_PL_Object_DecRef((PKIX_PL_Object *)(request), plContext); | 1647 PKIX_PL_Object_DecRef((PKIX_PL_Object *)(request), plContext); |
| 1652 | 1648 |
| 1653 if (err) { | 1649 if (err) { |
| 1654 PKIX_PL_Object_DecRef((PKIX_PL_Object *)err, plContext); | 1650 PKIX_PL_Object_DecRef((PKIX_PL_Object *)err, plContext); |
| 1655 return SECFailure; | 1651 return SECFailure; |
| 1656 } | 1652 } |
| 1657 return SECSuccess; | 1653 return SECSuccess; |
| 1658 } | 1654 } |
| OLD | NEW |