| 4365 | */ |
| 4366 | |
| 4367 | static int /* O - 0 on success, non-zero on error */ |
| 4368 | http_send(http_t *http, /* I - HTTP connection */ |
| 4369 | http_state_t request, /* I - Request code */ |
| 4370 | const char *uri) /* I - URI */ |
| 4371 | { |
| 4372 | int i; /* Looping var */ |
| 4373 | char buf[1024]; /* Encoded URI buffer */ |
| 4374 | const char *value; /* Field value */ |
| 4375 | static const char * const codes[] = /* Request code strings */ |
| 4376 | { |
| 4377 | NULL, |
| 4378 | "OPTIONS", |
| 4379 | "GET", |
| 4380 | NULL, |
| 4381 | "HEAD", |
| 4382 | "POST", |
| 4383 | NULL, |
| 4384 | NULL, |
| 4385 | "PUT", |
| 4386 | NULL, |
| 4387 | "DELETE", |
| 4388 | "TRACE", |
| 4389 | "CLOSE", |
| 4390 | NULL, |
| 4391 | NULL |
| 4392 | }; |
| 4393 | |
| 4394 | |
| 4395 | DEBUG_printf(("4http_send(http=%p, request=HTTP_%s, uri=\"%s\")", (void *)http, codes[request], uri)); |
| 4396 | |
| 4397 | if (http == NULL || uri == NULL) |
| 4398 | return (-1); |
| 4399 | |
| 4400 | /* |
| 4401 | * Set the User-Agent field if it isn't already... |
| 4402 | */ |
| 4403 | |
| 4404 | if (!http->fields[HTTP_FIELD_USER_AGENT]) |
| 4405 | { |
| 4406 | if (http->default_fields[HTTP_FIELD_USER_AGENT]) |
| 4407 | httpSetField(http, HTTP_FIELD_USER_AGENT, http->default_fields[HTTP_FIELD_USER_AGENT]); |
| 4408 | else |
| 4409 | httpSetField(http, HTTP_FIELD_USER_AGENT, cupsUserAgent()); |
| 4410 | } |
| 4411 | |
| 4412 | /* |
| 4413 | * Set the Accept-Encoding field if it isn't already... |
| 4414 | */ |
| 4415 | |
| 4416 | if (!http->fields[HTTP_FIELD_ACCEPT_ENCODING] && http->default_fields[HTTP_FIELD_ACCEPT_ENCODING]) |
| 4417 | httpSetField(http, HTTP_FIELD_ACCEPT_ENCODING, http->default_fields[HTTP_FIELD_ACCEPT_ENCODING]); |
| 4418 | |
| 4419 | /* |
| 4420 | * Encode the URI as needed... |
| 4421 | */ |
| 4422 | |
| 4423 | _httpEncodeURI(buf, uri, sizeof(buf)); |
| 4424 |
no test coverage detected