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

Function cupsPutFd

cups/getputfile.c:288–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286 */
287
288http_status_t /* O - HTTP status */
289cupsPutFd(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
290 const char *resource, /* I - Resource name */
291 int fd) /* I - File descriptor */
292{
293 ssize_t bytes; /* Number of bytes read */
294 int retries; /* Number of retries */
295 char buffer[8192]; /* Buffer for file */
296 http_status_t status; /* HTTP status from server */
297 int new_auth = 0; /* Using new auth information? */
298 int digest; /* Are we using Digest authentication? */
299
300
301 /*
302 * Range check input...
303 */
304
305 DEBUG_printf(("cupsPutFd(http=%p, resource=\"%s\", fd=%d)", (void *)http, resource, fd));
306
307 if (!resource || fd < 0)
308 {
309 if (http)
310 http->error = EINVAL;
311
312 return (HTTP_STATUS_ERROR);
313 }
314
315 if (!http)
316 if ((http = _cupsConnect()) == NULL)
317 return (HTTP_STATUS_SERVICE_UNAVAILABLE);
318
319 /*
320 * Then send PUT requests to the HTTP server...
321 */
322
323 retries = 0;
324
325 do
326 {
327 if (!_cups_strcasecmp(httpGetField(http, HTTP_FIELD_CONNECTION), "close"))
328 {
329 httpClearFields(http);
330 if (httpReconnect2(http, 30000, NULL))
331 {
332 status = HTTP_STATUS_ERROR;
333 break;
334 }
335 }
336
337 DEBUG_printf(("2cupsPutFd: starting attempt, authstring=\"%s\"...",
338 http->authstring));
339
340 httpClearFields(http);
341 httpSetField(http, HTTP_FIELD_TRANSFER_ENCODING, "chunked");
342 httpSetExpect(http, HTTP_STATUS_CONTINUE);
343
344 digest = http->authstring && !strncmp(http->authstring, "Digest ", 7);
345

Callers 1

cupsPutFileFunction · 0.85

Calls 15

_cupsConnectFunction · 0.85
_cups_strcasecmpFunction · 0.85
httpGetFieldFunction · 0.85
httpClearFieldsFunction · 0.85
httpReconnect2Function · 0.85
httpSetFieldFunction · 0.85
httpSetExpectFunction · 0.85
_httpSetDigestAuthStringFunction · 0.85
httpPutFunction · 0.85
httpWaitFunction · 0.85
httpUpdateFunction · 0.85
httpCheckFunction · 0.85

Tested by

no test coverage detected