MCPcopy Create free account
hub / github.com/OpenPrinting/cups / http_send

Function http_send

cups/http.c:4367–4546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4365 */
4366
4367static int /* O - 0 on success, non-zero on error */
4368http_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

Callers 7

httpDeleteFunction · 0.85
httpGetFunction · 0.85
httpHeadFunction · 0.85
httpOptionsFunction · 0.85
httpPostFunction · 0.85
httpPutFunction · 0.85
httpTraceFunction · 0.85

Calls 10

httpSetFieldFunction · 0.85
cupsUserAgentFunction · 0.85
_httpEncodeURIFunction · 0.85
httpReconnect2Function · 0.85
httpFlushWriteFunction · 0.85
httpPrintfFunction · 0.85
httpGetFieldFunction · 0.85
httpAddrPortFunction · 0.85
http_set_lengthFunction · 0.85
httpClearFieldsFunction · 0.85

Tested by

no test coverage detected