| 2973 | */ |
| 2974 | |
| 2975 | http_status_t /* O - HTTP status */ |
| 2976 | httpUpdate(http_t *http) /* I - HTTP connection */ |
| 2977 | { |
| 2978 | http_status_t status; /* Request status */ |
| 2979 | |
| 2980 | |
| 2981 | DEBUG_printf(("httpUpdate(http=%p), state=%s", (void *)http, httpStateString(http->state))); |
| 2982 | |
| 2983 | /* |
| 2984 | * Flush pending data, if any... |
| 2985 | */ |
| 2986 | |
| 2987 | if (http->wused) |
| 2988 | { |
| 2989 | DEBUG_puts("2httpUpdate: flushing buffer..."); |
| 2990 | |
| 2991 | if (httpFlushWrite(http) < 0) |
| 2992 | return (HTTP_STATUS_ERROR); |
| 2993 | } |
| 2994 | |
| 2995 | /* |
| 2996 | * If we haven't issued any commands, then there is nothing to "update"... |
| 2997 | */ |
| 2998 | |
| 2999 | if (http->state == HTTP_STATE_WAITING) |
| 3000 | return (HTTP_STATUS_CONTINUE); |
| 3001 | |
| 3002 | /* |
| 3003 | * Grab all of the lines we can from the connection... |
| 3004 | */ |
| 3005 | |
| 3006 | while (_httpUpdate(http, &status)); |
| 3007 | |
| 3008 | /* |
| 3009 | * See if there was an error... |
| 3010 | */ |
| 3011 | |
| 3012 | if (http->error == EPIPE && http->status > HTTP_STATUS_CONTINUE) |
| 3013 | { |
| 3014 | DEBUG_printf(("1httpUpdate: Returning status %d...", http->status)); |
| 3015 | return (http->status); |
| 3016 | } |
| 3017 | |
| 3018 | if (http->error) |
| 3019 | { |
| 3020 | DEBUG_printf(("1httpUpdate: socket error %d - %s", http->error, |
| 3021 | strerror(http->error))); |
| 3022 | http->status = HTTP_STATUS_ERROR; |
| 3023 | return (HTTP_STATUS_ERROR); |
| 3024 | } |
| 3025 | |
| 3026 | /* |
| 3027 | * Return the current status... |
| 3028 | */ |
| 3029 | |
| 3030 | return (status); |
| 3031 | } |
| 3032 | |