git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11332
a1ca3aef-8c08-0410-bb20-
df032aa958be
-/*
- * Local globals...
- */
-
-static const char * const ipp_states[] =
- { /* IPP state strings */
- "IPP_IDLE",
- "IPP_HEADER",
- "IPP_ATTRIBUTE",
- "IPP_STATE_DATA"
- };
-
-
/*
* Local functions...
*/
/*
* Local functions...
*/
cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
{
char line[32768], /* Line from client... */
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 */
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,
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
con->file);
#ifdef HAVE_SSL
gettimeofday(&(con->start), NULL);
cupsdLogClient(con, CUPSD_LOG_DEBUG, "%s %s HTTP/%d.%d",
gettimeofday(&(con->start), NULL);
cupsdLogClient(con, CUPSD_LOG_DEBUG, "%s %s HTTP/%d.%d",
+ httpStateString(con->operation) + 11, con->uri,
httpGetVersion(con->http) / 100,
httpGetVersion(con->http) % 100);
httpGetVersion(con->http) / 100,
httpGetVersion(con->http) % 100);
if (con->best && con->best->type != CUPSD_AUTH_NONE)
{
if (con->best && con->best->type != CUPSD_AUTH_NONE)
{
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_UNAUTHORIZED, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
if (!cupsdSendHeader(con, HTTP_STATUS_UNAUTHORIZED, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
* Do encryption stuff...
*/
* 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);
if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
return;
}
if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
return;
}
if (!cupsdStartTLS(con))
{
if (!cupsdStartTLS(con))
{
-#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");
httpSetField(con->http, HTTP_FIELD_ALLOW,
"GET, HEAD, OPTIONS, POST, PUT");
httpSetField(con->http, HTTP_FIELD_CONTENT_LENGTH, "0");
cupsdCloseClient(con);
return;
}
cupsdCloseClient(con);
return;
}
}
else if (!is_path_absolute(con->uri))
{
}
else if (!is_path_absolute(con->uri))
{
* Do encryption stuff...
*/
* 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;
}
if (!cupsdSendHeader(con, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL,
CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
return;
}
if (!cupsdStartTLS(con))
{
if (!cupsdStartTLS(con))
{
* Send 100-continue header...
*/
* Send 100-continue header...
*/
- if (!cupsdSendHeader(con, HTTP_STATUS_CONTINUE, NULL, CUPSD_AUTH_NONE))
+ if (httpWriteResponse(con->http, HTTP_STATUS_CONTINUE))
{
cupsdCloseClient(con);
return;
{
cupsdCloseClient(con);
return;
* Send 417-expectation-failed header...
*/
* Send 417-expectation-failed header...
*/
+ httpClearFields(con->http);
httpSetField(con->http, HTTP_FIELD_CONTENT_LENGTH, "0");
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)
{
}
else if (!WebInterface)
{
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_OK, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
if (!cupsdSendHeader(con, HTTP_STATUS_OK, NULL, CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
+ httpClearFields(con->http);
+
if (!cupsdSendHeader(con, HTTP_STATUS_OK, "text/html", CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
if (!cupsdSendHeader(con, HTTP_STATUS_OK, "text/html", CUPSD_AUTH_NONE))
{
cupsdCloseClient(con);
else if ((filename = get_file(con, &filestats, buf,
sizeof(buf))) == NULL)
{
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))
{
if (!cupsdSendHeader(con, HTTP_STATUS_NOT_FOUND, "text/html",
CUPSD_AUTH_NONE))
{
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
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);
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;
con->pipe_pid = pipe_command(con, fd, &(con->file), command, options, root);
con->pipe_status = HTTP_STATUS_OK;
+ httpClearFields(con->http);
+
* never disable it in that case.
*/
* 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);
if (code >= HTTP_STATUS_BAD_REQUEST && con->type != CUPSD_AUTH_NEGOTIATE)
httpSetKeepAlive(con->http, HTTP_KEEPALIVE_OFF);
* Send the HTTP status header...
*/
* 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
{
/*
* 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,
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, con->file);
if (httpGetState(con->http) != HTTP_STATE_GET_SEND &&
+ httpClearFields(con->http);
+
httpSetLength(con->http, filestats->st_size);
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,
httpSetLength(con->http, filestats->st_size);
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,
uri ? uri->values[0].string.text : "no URI",
con->http->hostname);
uri ? uri->values[0].string.text : "no URI",
con->http->hostname);
+ httpClearFields(con->http);
+
#ifdef CUPSD_USE_CHUNKING
/*
* Because older versions of CUPS (1.1.17 and older) and some IPP
#ifdef CUPSD_USE_CHUNKING
/*
* Because older versions of CUPS (1.1.17 and older) and some IPP