| 2760 | */ |
| 2761 | |
| 2762 | int /* O - 1 to continue, 0 to stop */ |
| 2763 | _httpUpdate(http_t *http, /* I - HTTP connection */ |
| 2764 | http_status_t *status) /* O - Current HTTP status */ |
| 2765 | { |
| 2766 | char line[_HTTP_MAX_BUFFER], /* Line from connection... */ |
| 2767 | *value; /* Pointer to value on line */ |
| 2768 | http_field_t field; /* Field index */ |
| 2769 | int major, minor; /* HTTP version numbers */ |
| 2770 | |
| 2771 | |
| 2772 | DEBUG_printf(("_httpUpdate(http=%p, status=%p), state=%s", (void *)http, (void *)status, httpStateString(http->state))); |
| 2773 | |
| 2774 | /* When doing non-blocking I/O, make sure we have a whole line... */ |
| 2775 | if (!http->blocking) |
| 2776 | { |
| 2777 | ssize_t bytes; /* Bytes "peeked" from connection */ |
| 2778 | |
| 2779 | /* See whether our read buffer is full... */ |
| 2780 | DEBUG_printf(("2_httpUpdate: used=%d", http->used)); |
| 2781 | |
| 2782 | if (http->used < sizeof(http->buffer)) |
| 2783 | { |
| 2784 | /* No, try filling in more data... */ |
| 2785 | if ((bytes = http_read(http, http->buffer + http->used, sizeof(http->buffer) - (size_t)http->used, /*timeout*/0)) > 0) |
| 2786 | { |
| 2787 | DEBUG_printf(("2_httpUpdate: Read %d bytes.", (int)bytes)); |
| 2788 | http->used += (int)bytes; |
| 2789 | } |
| 2790 | } |
| 2791 | |
| 2792 | /* Peek at the incoming data... */ |
| 2793 | if (!http->used || !memchr(http->buffer, '\n', (size_t)http->used)) |
| 2794 | { |
| 2795 | /* Don't have a full line, tell the reader to try again when there is more data... */ |
| 2796 | DEBUG_puts("1_htttpUpdate: No newline in buffer yet."); |
| 2797 | if ((size_t)http->used == sizeof(http->buffer)) |
| 2798 | *status = HTTP_STATUS_ERROR; |
| 2799 | else |
| 2800 | *status = HTTP_STATUS_CONTINUE; |
| 2801 | return (0); |
| 2802 | } |
| 2803 | |
| 2804 | DEBUG_puts("2_httpUpdate: Found newline in buffer."); |
| 2805 | } |
| 2806 | |
| 2807 | /* |
| 2808 | * Grab a single line from the connection... |
| 2809 | */ |
| 2810 | |
| 2811 | if (!httpGets(line, sizeof(line), http)) |
| 2812 | { |
| 2813 | DEBUG_puts("1_httpUpdate: Error reading request line."); |
| 2814 | *status = HTTP_STATUS_ERROR; |
| 2815 | return (0); |
| 2816 | } |
| 2817 | |
| 2818 | DEBUG_printf(("2_httpUpdate: Got \"%s\"", line)); |
| 2819 |
no test coverage detected