#endif /* HAVE_TCPD_H */
-/*
- * Local globals...
- */
-
-static const char * const ipp_states[] =
- { /* IPP state strings */
- "IPP_IDLE",
- "IPP_HEADER",
- "IPP_ATTRIBUTE",
- "IPP_STATE_DATA"
- };
-
-
/*
* Local functions...
*/
cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
{
char line[32768], /* Line from client... */
- operation[64], /* Operation code from socket */
locale[64], /* Locale */
*ptr; /* Pointer into strings */
http_status_t status; /* Transfer status */
httpIsChunked(con->http) ? "CHUNKED" : "LENGTH",
CUPS_LLCAST httpGetRemaining(con->http),
con->request,
- con->request ? ipp_states[con->request->state] : "",
+ con->request ? ippStateString(ippGetState(con->request)) : "",
con->file);
#ifdef HAVE_SSL
gettimeofday(&(con->start), NULL);
cupsdLogClient(con, CUPSD_LOG_DEBUG, "%s %s HTTP/%d.%d",
- operation, con->uri,
+ httpStateString(con->operation) + 11, con->uri,
httpGetVersion(con->http) / 100,
httpGetVersion(con->http) % 100);
if (con->best && con->best->type != CUPSD_AUTH_NONE)
{
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_UNAUTHORIZED, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
* Do encryption stuff...
*/
-# if 0
- if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL, CUPSD_AUTH_NONE))
- {
- cupsdCloseClient(con);
- return;
- }
-
- httpPrintf(con->http, "Connection: Upgrade\r\n");
- httpPrintf(con->http, "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
- httpPrintf(con->http, "Content-Length: 0\r\n");
- httpPrintf(con->http, "\r\n");
-
- if (cupsdFlushHeader(con) < 0)
- {
- cupsdCloseClient(con);
- return;
- }
+ httpClearFields(con->http);
-#else
if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
return;
}
-# endif /* 0 */
if (!cupsdStartTLS(con))
{
#endif /* HAVE_SSL */
}
-#if 0
- if (!cupsdSendHeader(con, HTTP_STATUS_OK, NULL, CUPSD_AUTH_NONE))
- {
- cupsdCloseClient(con);
- return;
- }
-
- httpPrintf(con->http, "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n");
- httpPrintf(con->http, "Content-Length: 0\r\n");
- httpPrintf(con->http, "\r\n");
-
- if (cupsdFlushHeader(con) < 0)
- {
- cupsdCloseClient(con);
- return;
- }
-#else
+ httpClearFields(con->http);
httpSetField(con->http, HTTP_FIELD_ALLOW,
"GET, HEAD, OPTIONS, POST, PUT");
httpSetField(con->http, HTTP_FIELD_CONTENT_LENGTH, "0");
cupsdCloseClient(con);
return;
}
-#endif /* 0 */
}
else if (!is_path_absolute(con->uri))
{
* Do encryption stuff...
*/
-# if 0
- if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL,
- CUPSD_AUTH_NONE))
- {
- cupsdCloseClient(con);
- return;
- }
+ httpClearFields(con->http);
- httpPrintf(con->http, "Connection: Upgrade\r\n");
- httpPrintf(con->http, "Upgrade: TLS/1.2,TLS/1.1,TLS/1.0\r\n");
- httpPrintf(con->http, "Content-Length: 0\r\n");
- httpPrintf(con->http, "\r\n");
-
- if (cupsdFlushHeader(con) < 0)
- {
- cupsdCloseClient(con);
- return;
- }
-# else
if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL,
CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
return;
}
-# endif /* 0 */
if (!cupsdStartTLS(con))
{
* Send 100-continue header...
*/
- if (!cupsdSendHeader(con, HTTP_STATUS_CONTINUE, NULL, CUPSD_AUTH_NONE))
+ if (httpWriteResponse(con->http, HTTP_STATUS_CONTINUE))
{
cupsdCloseClient(con);
return;
* Send 417-expectation-failed header...
*/
+ httpClearFields(con->http);
httpSetField(con->http, HTTP_FIELD_CONTENT_LENGTH, "0");
- if (!cupsdSendHeader(con, HTTP_STATUS_EXPECTATION_FAILED, NULL,
- CUPSD_AUTH_NONE))
- {
- cupsdCloseClient(con);
- return;
- }
+ cupsdSendError(con, HTTP_STATUS_EXPECTATION_FAILED, CUPSD_AUTH_NONE);
+ cupsdCloseClient(con);
+ return;
}
}
}
else if (!WebInterface)
{
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_OK, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
* CGI output...
*/
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_OK, "text/html", CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
else if ((filename = get_file(con, &filestats, buf,
sizeof(buf))) == NULL)
{
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_NOT_FOUND, "text/html",
CUPSD_AUTH_NONE))
{
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
+ httpClearFields(con->http);
+
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,
httpGetDateString(filestats.st_mtime));
httpSetLength(con->http, filestats.st_size);
con->pipe_pid = pipe_command(con, fd, &(con->file), command, options, root);
con->pipe_status = HTTP_STATUS_OK;
+ httpClearFields(con->http);
+
if (fd >= 0)
close(fd);
* never disable it in that case.
*/
+ httpClearFields(con->http);
+
if (code >= HTTP_STATUS_BAD_REQUEST && con->type != CUPSD_AUTH_NEGOTIATE)
httpSetKeepAlive(con->http, HTTP_KEEPALIVE_OFF);
* Send the HTTP status header...
*/
- if (code == HTTP_STATUS_CONTINUE)
- {
- /*
- * 100-continue doesn't send any headers...
- */
-
- return (!httpWriteResponse(con->http, HTTP_STATUS_CONTINUE));
- }
- else if (code == HTTP_STATUS_CUPS_WEBIF_DISABLED)
+ if (code == HTTP_STATUS_CUPS_WEBIF_DISABLED)
{
/*
* Treat our special "web interface is disabled" status as "200 OK" for web
httpIsChunked(con->http) ? "CHUNKED" : "LENGTH",
CUPS_LLCAST httpGetLength2(con->http),
con->response,
- con->response ? ipp_states[con->response->state] : "",
+ con->response ? ippStateString(ippGetState(con->request)) : "",
con->pipe_pid, con->file);
if (httpGetState(con->http) != HTTP_STATE_GET_SEND &&
con->pipe_pid = 0;
+ httpClearFields(con->http);
+
httpSetLength(con->http, filestats->st_size);
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,