/*
- * "$Id: http.c,v 1.82.2.32 2003/05/09 16:06:43 mike Exp $"
+ * "$Id: http.c,v 1.82.2.33 2003/05/09 18:35:37 mike Exp $"
*
* HTTP routines for the Common UNIX Printing System (CUPS).
*
* Buffer small reads for better performance...
*/
+ if (!http->blocking && !httpWait(http, 1000))
+ return (0);
+
if (http->data_remaining > sizeof(http->buffer))
bytes = sizeof(http->buffer);
else
bytes = http->data_remaining;
- if (!http->blocking && !httpWait(http, 1000))
- return (0);
-
#ifdef HAVE_SSL
if (http->tls)
bytes = http_read_ssl(http, http->buffer, bytes);
}
#endif /* WIN32 */
}
- else if (bytes == 0)
+ else
{
http->error = EPIPE;
return (0);
}
#ifdef HAVE_SSL
else if (http->tls)
- {
- if (!http->blocking && !httpWait(http, 1000))
- return (0);
bytes = http_read_ssl(http, buffer, length);
- }
#endif /* HAVE_SSL */
else
{
if (!http->blocking && !httpWait(http, 1000))
return (0);
+
DEBUG_printf(("httpRead: reading %d bytes from socket...\n", length));
bytes = recv(http->fd, buffer, length, 0);
DEBUG_printf(("httpRead: read %d bytes from socket...\n", bytes));
http->error = errno;
#endif /* WIN32 */
}
- else if (bytes == 0)
+ else
{
http->error = EPIPE;
- return 0;
+ return (0);
}
if (http->data_remaining == 0)
* No newline; see if there is more data to be read...
*/
- if (!http->blocking && !httpWait(http, 1000))
- return (NULL);
-
#ifdef HAVE_SSL
if (http->tls)
bytes = http_read_ssl(http, bufend, HTTP_MAX_BUFFER - http->used);
else
#endif /* HAVE_SSL */
- bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0);
+ if (!http->blocking && !httpWait(http, 1000))
+ return (NULL);
+ else
+ bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0);
if (bytes < 0)
{
}
else if (bytes == 0)
{
- http->error = EPIPE;
+ http->error = EPIPE;
return (NULL);
}
/*
- * End of "$Id: http.c,v 1.82.2.32 2003/05/09 16:06:43 mike Exp $".
+ * End of "$Id: http.c,v 1.82.2.33 2003/05/09 18:35:37 mike Exp $".
*/
/*
- * "$Id: http.h,v 1.33.2.17 2003/03/13 05:45:29 mike Exp $"
+ * "$Id: http.h,v 1.33.2.18 2003/05/09 18:35:38 mike Exp $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
extern const char *httpStatus(http_status_t status);
extern int httpTrace(http_t *http, const char *uri);
extern http_status_t httpUpdate(http_t *http);
-extern int httpWait(http_t *http, int msec);
extern int httpWrite(http_t *http, const char *buffer, int length);
extern char *httpEncode64(char *out, const char *in);
extern char *httpDecode64(char *out, const char *in);
extern void httpClearCookie(http_t *http);
#define httpGetCookie(http) ((http)->cookie)
extern void httpSetCookie(http_t *http, const char *cookie);
+extern int httpWait(http_t *http, int msec);
/**** New in CUPS 1.2 ****/
extern int httpAddrEqual(const http_addr_t *addr1,
#endif /* !_IPP_HTTP_H_ */
/*
- * End of "$Id: http.h,v 1.33.2.17 2003/03/13 05:45:29 mike Exp $".
+ * End of "$Id: http.h,v 1.33.2.18 2003/05/09 18:35:38 mike Exp $".
*/