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

Function httpFlush

cups/http.c:634–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632 */
633
634void
635httpFlush(http_t *http) /* I - HTTP connection */
636{
637 char buffer[8192]; /* Junk buffer */
638 int blocking; /* To block or not to block */
639 http_state_t oldstate; /* Old state */
640
641
642 DEBUG_printf(("httpFlush(http=%p), state=%s", (void *)http, httpStateString(http->state)));
643
644 /*
645 * Nothing to do if we are in the "waiting" state...
646 */
647
648 if (http->state == HTTP_STATE_WAITING)
649 return;
650
651 /*
652 * Temporarily set non-blocking mode so we don't get stuck in httpRead()...
653 */
654
655 blocking = http->blocking;
656 http->blocking = 0;
657
658 /*
659 * Read any data we can...
660 */
661
662 oldstate = http->state;
663 while (httpRead2(http, buffer, sizeof(buffer)) > 0);
664
665 /*
666 * Restore blocking and reset the connection if we didn't get all of
667 * the remaining data...
668 */
669
670 http->blocking = blocking;
671
672 if (http->state == oldstate && http->state != HTTP_STATE_WAITING &&
673 http->fd >= 0)
674 {
675 /*
676 * Didn't get the data back, so close the current connection.
677 */
678
679#ifdef HAVE_LIBZ
680 if (http->coding)
681 http_content_coding_finish(http);
682#endif /* HAVE_LIBZ */
683
684 DEBUG_puts("1httpFlush: Setting state to HTTP_STATE_WAITING and closing.");
685
686 http->state = HTTP_STATE_WAITING;
687
688#ifdef HAVE_TLS
689 if (http->tls)
690 _httpTLSStop(http);
691#endif /* HAVE_TLS */

Callers 15

list_serviceFunction · 0.85
ifFunction · 0.85
process_ippFunction · 0.85
do_am_printerFunction · 0.85
cupsGetFdFunction · 0.85
ifFunction · 0.85
cupsPutFdFunction · 0.85
mainFunction · 0.85
ifFunction · 0.85
http_tls_upgradeFunction · 0.85
cupsGetDevicesFunction · 0.85
cupsDoIORequestFunction · 0.85

Calls 5

httpStateStringFunction · 0.85
httpRead2Function · 0.85
httpAddrCloseFunction · 0.85
_httpTLSStopFunction · 0.70

Tested by 2

mainFunction · 0.68
ifFunction · 0.68