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

Function cupsGetResponse

cups/request.c:310–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308 */
309
310ipp_t * /* O - Response or @code NULL@ on HTTP error */
311cupsGetResponse(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
312 const char *resource) /* I - HTTP resource for POST */
313{
314 http_status_t status; /* HTTP status */
315 ipp_state_t state; /* IPP read state */
316 ipp_t *response = NULL; /* IPP response */
317
318
319 DEBUG_printf(("cupsGetResponse(http=%p, resource=\"%s\")", (void *)http, resource));
320 DEBUG_printf(("1cupsGetResponse: http->state=%d", http ? http->state : HTTP_STATE_ERROR));
321
322 /*
323 * Connect to the default server as needed...
324 */
325
326 if (!http)
327 {
328 _cups_globals_t *cg = _cupsGlobals();
329 /* Pointer to library globals */
330
331 if ((http = cg->http) == NULL)
332 {
333 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No active connection."), 1);
334 DEBUG_puts("1cupsGetResponse: No active connection - returning NULL.");
335 return (NULL);
336 }
337 }
338
339 if (http->state != HTTP_STATE_POST_RECV && http->state != HTTP_STATE_POST_SEND)
340 {
341 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No request sent."), 1);
342 DEBUG_puts("1cupsGetResponse: Not in POST state - returning NULL.");
343 return (NULL);
344 }
345
346 /*
347 * Check for an unfinished chunked request...
348 */
349
350 if (http->data_encoding == HTTP_ENCODING_CHUNKED)
351 {
352 /*
353 * Send a 0-length chunk to finish off the request...
354 */
355
356 DEBUG_puts("2cupsGetResponse: Finishing chunked POST...");
357
358 if (httpWrite2(http, "", 0) < 0)
359 {
360 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to finish request."), 1);
361 return (NULL);
362 }
363 }
364
365 /*
366 * Wait for a response from the server...
367 */

Callers 6

do_monitor_printer_stateFunction · 0.85
do_testFunction · 0.85
mainFunction · 0.85
cupsFinishDestDocumentFunction · 0.85
cupsFinishDocumentFunction · 0.85
cupsDoIORequestFunction · 0.85

Calls 14

_cupsGlobalsFunction · 0.85
_cupsSetErrorFunction · 0.85
httpWrite2Function · 0.85
httpUpdateFunction · 0.85
ippNewFunction · 0.85
ippReadFunction · 0.85
httpFlushFunction · 0.85
ippDeleteFunction · 0.85
_cupsSetHTTPErrorFunction · 0.85
cupsDoAuthenticationFunction · 0.85
httpReconnect2Function · 0.85
httpEncryptionFunction · 0.85

Tested by

no test coverage detected