| 2161 | */ |
| 2162 | |
| 2163 | http_state_t /* O - New state of connection */ |
| 2164 | httpReadRequest(http_t *http, /* I - HTTP connection */ |
| 2165 | char *uri, /* I - URI buffer */ |
| 2166 | size_t urilen) /* I - Size of URI buffer */ |
| 2167 | { |
| 2168 | char line[4096], /* HTTP request line */ |
| 2169 | *req_method, /* HTTP request method */ |
| 2170 | *req_uri, /* HTTP request URI */ |
| 2171 | *req_version; /* HTTP request version number string */ |
| 2172 | |
| 2173 | |
| 2174 | /* |
| 2175 | * Range check input... |
| 2176 | */ |
| 2177 | |
| 2178 | DEBUG_printf(("httpReadRequest(http=%p, uri=%p, urilen=" CUPS_LLFMT ")", (void *)http, (void *)uri, CUPS_LLCAST urilen)); |
| 2179 | |
| 2180 | if (uri) |
| 2181 | *uri = '\0'; |
| 2182 | |
| 2183 | if (!http || !uri || urilen < 1) |
| 2184 | { |
| 2185 | DEBUG_puts("1httpReadRequest: Bad arguments, returning HTTP_STATE_ERROR."); |
| 2186 | return (HTTP_STATE_ERROR); |
| 2187 | } |
| 2188 | else if (http->state != HTTP_STATE_WAITING) |
| 2189 | { |
| 2190 | DEBUG_printf(("1httpReadRequest: Bad state %s, returning HTTP_STATE_ERROR.", |
| 2191 | httpStateString(http->state))); |
| 2192 | return (HTTP_STATE_ERROR); |
| 2193 | } |
| 2194 | |
| 2195 | /* |
| 2196 | * Reset state... |
| 2197 | */ |
| 2198 | |
| 2199 | httpClearFields(http); |
| 2200 | |
| 2201 | http->activity = time(NULL); |
| 2202 | http->data_encoding = HTTP_ENCODING_FIELDS; |
| 2203 | http->data_remaining = 0; |
| 2204 | http->keep_alive = HTTP_KEEPALIVE_OFF; |
| 2205 | http->status = HTTP_STATUS_OK; |
| 2206 | http->version = HTTP_VERSION_1_1; |
| 2207 | |
| 2208 | /* |
| 2209 | * Read a line from the socket... |
| 2210 | */ |
| 2211 | |
| 2212 | if (!httpGets(line, sizeof(line), http)) |
| 2213 | { |
| 2214 | DEBUG_puts("1httpReadRequest: Unable to read, returning HTTP_STATE_ERROR"); |
| 2215 | return (HTTP_STATE_ERROR); |
| 2216 | } |
| 2217 | |
| 2218 | if (!line[0]) |
| 2219 | { |
| 2220 | DEBUG_puts("1httpReadRequest: Blank line, returning HTTP_STATE_WAITING"); |
no test coverage detected