| 4551 | */ |
| 4552 | |
| 4553 | static off_t /* O - Remainder or -1 on error */ |
| 4554 | http_set_length(http_t *http) /* I - Connection */ |
| 4555 | { |
| 4556 | off_t remaining; /* Remainder */ |
| 4557 | |
| 4558 | |
| 4559 | DEBUG_printf(("4http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state))); |
| 4560 | |
| 4561 | if ((remaining = httpGetLength2(http)) >= 0) |
| 4562 | { |
| 4563 | if (http->mode == _HTTP_MODE_SERVER && |
| 4564 | http->state != HTTP_STATE_GET_SEND && |
| 4565 | http->state != HTTP_STATE_PUT && |
| 4566 | http->state != HTTP_STATE_POST && |
| 4567 | http->state != HTTP_STATE_POST_SEND) |
| 4568 | { |
| 4569 | DEBUG_puts("5http_set_length: Not setting data_encoding/remaining."); |
| 4570 | return (remaining); |
| 4571 | } |
| 4572 | |
| 4573 | if (!_cups_strcasecmp(httpGetField(http, HTTP_FIELD_TRANSFER_ENCODING), "chunked")) |
| 4574 | { |
| 4575 | DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_CHUNKED."); |
| 4576 | http->data_encoding = HTTP_ENCODING_CHUNKED; |
| 4577 | } |
| 4578 | else |
| 4579 | { |
| 4580 | DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_LENGTH."); |
| 4581 | http->data_encoding = HTTP_ENCODING_LENGTH; |
| 4582 | } |
| 4583 | |
| 4584 | DEBUG_printf(("5http_set_length: Setting data_remaining to " CUPS_LLFMT ".", CUPS_LLCAST remaining)); |
| 4585 | http->data_remaining = remaining; |
| 4586 | |
| 4587 | if (remaining <= INT_MAX) |
| 4588 | http->_data_remaining = (int)remaining; |
| 4589 | else |
| 4590 | http->_data_remaining = INT_MAX; |
| 4591 | } |
| 4592 | |
| 4593 | return (remaining); |
| 4594 | } |
| 4595 | |
| 4596 | /* |
| 4597 | * 'http_set_timeout()' - Set the socket timeout values. |
no test coverage detected