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

Function httpRead2

cups/http.c:1956–2154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1954 */
1955
1956ssize_t /* O - Number of bytes read */
1957httpRead2(http_t *http, /* I - HTTP connection */
1958 char *buffer, /* I - Buffer for data */
1959 size_t length) /* I - Maximum number of bytes */
1960{
1961 ssize_t bytes; /* Bytes read */
1962
1963
1964#ifdef HAVE_LIBZ
1965 DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") coding=%d data_encoding=%d data_remaining=" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http ? http->coding : 0, http ? http->data_encoding : 0, CUPS_LLCAST (http ? http->data_remaining : -1)));
1966#else
1967 DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") data_encoding=%d data_remaining=" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http ? http->data_encoding : 0, CUPS_LLCAST (http ? http->data_remaining : -1)));
1968#endif /* HAVE_LIBZ */
1969
1970 if (http == NULL || buffer == NULL)
1971 return (-1);
1972
1973 http->activity = time(NULL);
1974 http->error = 0;
1975
1976 if (length <= 0)
1977 return (0);
1978
1979#ifdef HAVE_LIBZ
1980 if (http->coding >= _HTTP_CODING_GUNZIP)
1981 {
1982 do
1983 {
1984 if (((z_stream *)http->stream)->avail_in > 0)
1985 {
1986 int zerr; /* Decompressor error */
1987
1988 DEBUG_printf(("2httpRead2: avail_in=%d, avail_out=%d",
1989 (int)((z_stream *)http->stream)->avail_in, (int)length));
1990
1991 ((z_stream *)http->stream)->next_out = (Bytef *)buffer;
1992 ((z_stream *)http->stream)->avail_out = (uInt)length;
1993
1994 if ((zerr = inflate((z_stream *)http->stream, Z_SYNC_FLUSH)) < Z_OK)
1995 {
1996 DEBUG_printf(("2httpRead2: zerr=%d", zerr));
1997#ifdef DEBUG
1998 http_debug_hex("2httpRead2", (char *)http->sbuffer, (int)((z_stream *)http->stream)->avail_in);
1999#endif /* DEBUG */
2000
2001 http->error = EIO;
2002 return (-1);
2003 }
2004
2005 bytes = (ssize_t)(length - ((z_stream *)http->stream)->avail_out);
2006
2007 DEBUG_printf(("2httpRead2: avail_in=%d, avail_out=%d, bytes=%d",
2008 ((z_stream *)http->stream)->avail_in, ((z_stream *)http->stream)->avail_out,
2009 (int)bytes));
2010 }
2011 else
2012 bytes = 0;
2013

Callers 12

finish_document_dataFunction · 0.85
finish_document_uriFunction · 0.85
flush_document_dataFunction · 0.85
cupsdReadClientFunction · 0.85
do_am_printerFunction · 0.85
cupsGetFdFunction · 0.85
mainFunction · 0.85
httpFlushFunction · 0.85
httpReadFunction · 0.85
ipp_read_httpFunction · 0.85
cupsDoIORequestFunction · 0.85
cupsReadResponseDataFunction · 0.85

Calls 6

http_debug_hexFunction · 0.85
http_read_bufferedFunction · 0.85
http_read_chunkFunction · 0.85
httpGetsFunction · 0.85
httpStateStringFunction · 0.85

Tested by 1

mainFunction · 0.68