/*
- * "$Id: http.c,v 1.41 1999/07/27 16:27:24 mike Exp $"
+ * "$Id: http.c,v 1.42 1999/08/12 20:31:33 mike Exp $"
*
* HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
*
*
* httpInitialize() - Initialize the HTTP interface library and set the
* default HTTP proxy (if any).
+ * httpCheck() - Check to see if there is a pending response from
+ * the server.
* httpClose() - Close an HTTP connection...
* httpConnect() - Connect to a HTTP server.
* httpReconnect() - Reconnect to a HTTP server...
}
+/*
+ * 'httpCheck()' - Check to see if there is a pending response from the server.
+ */
+
+int /* O - 0 = no data, 1 = data available */
+httpCheck(http_t *http) /* I - HTTP connection */
+{
+ fd_set input; /* Input set for select() */
+ struct timeval timeout; /* Timeout */
+
+
+ /*
+ * First see if there is data in the buffer...
+ */
+
+ if (http == NULL)
+ return (0);
+
+ if (http->used)
+ return (1);
+
+ /*
+ * Then try doing a select() to poll the socket...
+ */
+
+ FD_ZERO(&input);
+ FD_SET(http->fd, &input);
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0);
+}
+
+
/*
* 'httpClose()' - Close an HTTP connection...
*/
if (bytes < 0)
{
DEBUG_puts("httpWrite: error writing data...\n");
+
return (-1);
}
* No newline; see if there is more data to be read...
*/
- if ((bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0)) < 1)
+ if ((bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0)) < 0)
{
/*
* Nope, can't get a line this time...
*/
+ if (errno == EPIPE)
+ continue;
+
+ DEBUG_printf(("httpGets(): recv() error %d!\n", errno));
+
return (NULL);
}
else
if (http->used > 0)
memcpy(http->buffer, bufptr, http->used);
+ DEBUG_printf(("httpGets(): Returning \"%s\"\n", line));
return (line);
}
else if (*bufptr == 0x0d)
*lineptr++ = *bufptr++;
}
+ DEBUG_puts("httpGets(): No new line available!");
+
return (NULL);
}
if (request == HTTP_POST || request == HTTP_PUT)
http->state ++;
+ http->status = HTTP_CONTINUE;
+
if (httpPrintf(http, "%s %s HTTP/1.1\r\n", codes[request], buf) < 1)
{
/*
/*
- * End of "$Id: http.c,v 1.41 1999/07/27 16:27:24 mike Exp $".
+ * End of "$Id: http.c,v 1.42 1999/08/12 20:31:33 mike Exp $".
*/
/*
- * "$Id: http.h,v 1.21 1999/07/12 16:09:36 mike Exp $"
+ * "$Id: http.h,v 1.22 1999/08/12 20:31:35 mike Exp $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
*/
# define httpBlocking(http,b) (http)->blocking = (b)
+extern int httpCheck(http_t *http);
# define httpClearFields(http) memset((http)->fields, 0, sizeof((http)->fields)),\
httpSetField((http), HTTP_FIELD_HOST, (http)->hostname)
extern void httpClose(http_t *http);
#endif /* !_CUPS_HTTP_H_ */
/*
- * End of "$Id: http.h,v 1.21 1999/07/12 16:09:36 mike Exp $".
+ * End of "$Id: http.h,v 1.22 1999/08/12 20:31:35 mike Exp $".
*/
/*
- * "$Id: client.c,v 1.30 1999/07/21 20:29:59 mike Exp $"
+ * "$Id: client.c,v 1.31 1999/08/12 20:31:41 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
}
else if ((status = IsAuthorized(con)) != HTTP_OK)
{
- if (!SendError(con, status))
- {
- CloseClient(con);
- return (0);
- }
+ SendError(con, status);
+ CloseClient(con);
+ return (0);
}
else switch (con->http.state)
{
/*
- * End of "$Id: client.c,v 1.30 1999/07/21 20:29:59 mike Exp $".
+ * End of "$Id: client.c,v 1.31 1999/08/12 20:31:41 mike Exp $".
*/