2 * "$Id: request.c 7946 2008-09-16 23:27:54Z mike $"
4 * IPP utilities for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * cupsDoFileRequest() - Do an IPP request with a file.
20 * cupsDoIORequest() - Do an IPP request with file descriptors.
21 * cupsDoRequest() - Do an IPP request.
22 * cupsGetResponse() - Get a response to an IPP request.
23 * cupsLastError() - Return the last IPP status code.
24 * cupsLastErrorString() - Return the last IPP status-message.
25 * _cupsNextDelay() - Return the next retry delay value.
26 * cupsReadResponseData() - Read additional data after the IPP response.
27 * cupsSendRequest() - Send an IPP request.
28 * cupsWriteRequestData() - Write additional data after an IPP request.
29 * _cupsConnect() - Get the default server connection...
30 * _cupsSetError() - Set the last IPP status code and status-message.
31 * _cupsSetHTTPError() - Set the last error using the HTTP status.
35 * Include necessary headers...
38 #include "cups-private.h"
41 #if defined(WIN32) || defined(__EMX__)
45 #endif /* WIN32 || __EMX__ */
52 * 'cupsDoFileRequest()' - Do an IPP request with a file.
54 * This function sends the IPP request to the specified server, retrying
55 * and authenticating as necessary. The request is freed with @link ippDelete@
56 * after receiving a valid IPP response.
59 ipp_t
* /* O - Response data */
60 cupsDoFileRequest(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
61 ipp_t
*request
, /* I - IPP request */
62 const char *resource
, /* I - HTTP resource for POST */
63 const char *filename
) /* I - File to send or @code NULL@ for none */
65 ipp_t
*response
; /* IPP response data */
66 int infile
; /* Input file */
69 DEBUG_printf(("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", "
70 "filename=\"%s\")", http
, request
,
71 request
? ippOpString(request
->request
.op
.operation_id
) : "?",
76 if ((infile
= open(filename
, O_RDONLY
| O_BINARY
)) < 0)
79 * Can't get file information!
82 _cupsSetError(errno
== ENOENT
? IPP_NOT_FOUND
: IPP_NOT_AUTHORIZED
,
93 response
= cupsDoIORequest(http
, request
, resource
, infile
, -1);
103 * 'cupsDoIORequest()' - Do an IPP request with file descriptors.
105 * This function sends the IPP request to the specified server, retrying
106 * and authenticating as necessary. The request is freed with ippDelete()
107 * after receiving a valid IPP response.
109 * If "infile" is a valid file descriptor, cupsDoIORequest() copies
110 * all of the data from the file after the IPP request message.
112 * If "outfile" is a valid file descriptor, cupsDoIORequest() copies
113 * all of the data after the IPP response message to the file.
115 * @since CUPS 1.3/Mac OS X 10.5@
118 ipp_t
* /* O - Response data */
119 cupsDoIORequest(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
120 ipp_t
*request
, /* I - IPP request */
121 const char *resource
, /* I - HTTP resource for POST */
122 int infile
, /* I - File to read from or -1 for none */
123 int outfile
) /* I - File to write to or -1 for none */
125 ipp_t
*response
= NULL
; /* IPP response data */
126 size_t length
= 0; /* Content-Length value */
127 http_status_t status
; /* Status of HTTP request */
128 struct stat fileinfo
; /* File information */
129 int bytes
; /* Number of bytes read/written */
130 char buffer
[32768]; /* Output buffer */
133 DEBUG_printf(("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", "
134 "infile=%d, outfile=%d)", http
, request
,
135 request
? ippOpString(request
->request
.op
.operation_id
) : "?",
136 resource
, infile
, outfile
));
139 * Range check input...
142 if (!request
|| !resource
)
146 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
152 * Get the default connection as needed...
156 if ((http
= _cupsConnect()) == NULL
)
164 * See if we have a file to send...
169 if (fstat(infile
, &fileinfo
))
172 * Can't get file information!
175 _cupsSetError(errno
== EBADF
? IPP_NOT_FOUND
: IPP_NOT_AUTHORIZED
,
184 if (fileinfo
.st_mode
& _S_IFDIR
)
186 if (S_ISDIR(fileinfo
.st_mode
))
190 * Can't send a directory...
195 _cupsSetError(IPP_NOT_POSSIBLE
, strerror(EISDIR
), 0);
201 if (!S_ISREG(fileinfo
.st_mode
))
202 length
= 0; /* Chunk when piping */
205 length
= ippLength(request
) + fileinfo
.st_size
;
208 length
= ippLength(request
);
210 DEBUG_printf(("2cupsDoIORequest: Request length=%ld, total length=%ld",
211 (long)ippLength(request
), (long)length
));
214 * Clear any "Local" authentication data since it is probably stale...
217 if (http
->authstring
&& !strncmp(http
->authstring
, "Local ", 6))
218 httpSetAuthString(http
, NULL
, NULL
);
221 * Loop until we can send the request without authorization problems.
224 while (response
== NULL
)
226 DEBUG_puts("2cupsDoIORequest: setup...");
229 * Send the request...
232 status
= cupsSendRequest(http
, request
, resource
, length
);
234 DEBUG_printf(("2cupsDoIORequest: status=%d", status
));
236 if (status
== HTTP_CONTINUE
&& request
->state
== IPP_DATA
&& infile
>= 0)
238 DEBUG_puts("2cupsDoIORequest: file write...");
241 * Send the file with the request...
245 if (S_ISREG(fileinfo
.st_mode
))
247 lseek(infile
, 0, SEEK_SET
);
249 while ((bytes
= (int)read(infile
, buffer
, sizeof(buffer
))) > 0)
253 _httpUpdate(http
, &status
);
255 if (status
>= HTTP_MULTIPLE_CHOICES
)
259 if (httpWrite2(http
, buffer
, bytes
) < bytes
)
265 * Get the server's response...
268 if (status
== HTTP_CONTINUE
|| status
== HTTP_OK
)
270 response
= cupsGetResponse(http
, resource
);
271 status
= http
->status
;
276 DEBUG_printf(("2cupsDoIORequest: status=%d", status
));
278 if (status
== HTTP_ERROR
||
279 (status
>= HTTP_BAD_REQUEST
&& status
!= HTTP_UNAUTHORIZED
&&
280 status
!= HTTP_UPGRADE_REQUIRED
))
282 _cupsSetHTTPError(status
);
291 * Write trailing data to file...
294 while ((bytes
= (int)httpRead2(http
, buffer
, sizeof(buffer
))) > 0)
295 if (write(outfile
, buffer
, bytes
) < bytes
)
301 * Flush any remaining data...
310 * Delete the original request and return the response...
320 * 'cupsDoRequest()' - Do an IPP request.
322 * This function sends the IPP request to the specified server, retrying
323 * and authenticating as necessary. The request is freed with ippDelete()
324 * after receiving a valid IPP response.
327 ipp_t
* /* O - Response data */
328 cupsDoRequest(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
329 ipp_t
*request
, /* I - IPP request */
330 const char *resource
) /* I - HTTP resource for POST */
332 DEBUG_printf(("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")",
334 request
? ippOpString(request
->request
.op
.operation_id
) : "?",
337 return (cupsDoIORequest(http
, request
, resource
, -1, -1));
342 * 'cupsGetResponse()' - Get a response to an IPP request.
344 * Use this function to get the response for an IPP request sent using
345 * cupsSendDocument() or cupsSendRequest(). For requests that return
346 * additional data, use httpRead() after getting a successful response.
348 * @since CUPS 1.4/Mac OS X 10.6@
351 ipp_t
* /* O - Response or @code NULL@ on HTTP error */
352 cupsGetResponse(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
353 const char *resource
) /* I - HTTP resource for POST */
355 http_status_t status
; /* HTTP status */
356 ipp_state_t state
; /* IPP read state */
357 ipp_t
*response
= NULL
; /* IPP response */
360 DEBUG_printf(("cupsGetResponse(http=%p, resource=\"%s\")", http
, resource
));
363 * Connect to the default server as needed...
367 http
= _cupsConnect();
369 if (!http
|| (http
->state
!= HTTP_POST_RECV
&& http
->state
!= HTTP_POST_SEND
))
373 * Check for an unfinished chunked request...
376 if (http
->data_encoding
== HTTP_ENCODE_CHUNKED
)
379 * Send a 0-length chunk to finish off the request...
382 DEBUG_puts("2cupsGetResponse: Finishing chunked POST...");
384 if (httpWrite2(http
, "", 0) < 0)
389 * Wait for a response from the server...
392 DEBUG_printf(("2cupsGetResponse: Update loop, http->status=%d...",
397 status
= httpUpdate(http
);
399 while (http
->state
== HTTP_POST_RECV
);
401 DEBUG_printf(("2cupsGetResponse: status=%d", status
));
403 if (status
== HTTP_OK
)
406 * Get the IPP response...
411 while ((state
= ippRead(http
, response
)) != IPP_DATA
)
412 if (state
== IPP_ERROR
)
415 if (state
== IPP_ERROR
)
418 * Flush remaining data and delete the response...
421 DEBUG_puts("1cupsGetResponse: IPP read error!");
428 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
431 else if (status
!= HTTP_ERROR
)
434 * Flush any error message...
440 * Then handle encryption and authentication...
443 if (status
== HTTP_UNAUTHORIZED
)
446 * See if we can do authentication...
449 DEBUG_puts("2cupsGetResponse: Need authorization...");
451 if (!cupsDoAuthentication(http
, "POST", resource
))
454 status
= HTTP_AUTHORIZATION_CANCELED
;
458 else if (status
== HTTP_UPGRADE_REQUIRED
)
461 * Force a reconnect with encryption...
464 DEBUG_puts("2cupsGetResponse: Need encryption...");
466 if (!httpReconnect(http
))
467 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
);
469 #endif /* HAVE_SSL */
474 ipp_attribute_t
*attr
; /* status-message attribute */
477 attr
= ippFindAttribute(response
, "status-message", IPP_TAG_TEXT
);
479 DEBUG_printf(("1cupsGetResponse: status-code=%s, status-message=\"%s\"",
480 ippErrorString(response
->request
.status
.status_code
),
481 attr
? attr
->values
[0].string
.text
: ""));
483 _cupsSetError(response
->request
.status
.status_code
,
484 attr
? attr
->values
[0].string
.text
:
485 ippErrorString(response
->request
.status
.status_code
), 0);
487 else if (status
!= HTTP_OK
)
488 _cupsSetHTTPError(status
);
495 * 'cupsLastError()' - Return the last IPP status code.
498 ipp_status_t
/* O - IPP status code from last request */
501 return (_cupsGlobals()->last_error
);
506 * 'cupsLastErrorString()' - Return the last IPP status-message.
508 * @since CUPS 1.2/Mac OS X 10.5@
511 const char * /* O - status-message text from last request */
512 cupsLastErrorString(void)
514 return (_cupsGlobals()->last_status_message
);
519 * '_cupsNextDelay()' - Return the next retry delay value.
521 * This function currently returns the Fibonacci sequence 1 1 2 3 5 8.
523 * Pass 0 for the current delay value to initialize the sequence.
526 int /* O - Next delay value */
527 _cupsNextDelay(int current
, /* I - Current delay value or 0 */
528 int *previous
) /* IO - Previous delay value */
530 int next
; /* Next delay value */
535 next
= (current
+ *previous
) % 12;
536 *previous
= next
< current
? 0 : current
;
549 * 'cupsReadResponseData()' - Read additional data after the IPP response.
551 * This function is used after cupsGetResponse() to read the PPD or document
552 * files for CUPS_GET_PPD and CUPS_GET_DOCUMENT requests, respectively.
554 * @since CUPS 1.4/Mac OS X 10.6@
557 ssize_t
/* O - Bytes read, 0 on EOF, -1 on error */
558 cupsReadResponseData(
559 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
560 char *buffer
, /* I - Buffer to use */
561 size_t length
) /* I - Number of bytes to read */
564 * Get the default connection as needed...
567 DEBUG_printf(("cupsReadResponseData(http=%p, buffer=%p, "
568 "length=" CUPS_LLFMT
")", http
, buffer
, CUPS_LLCAST length
));
572 _cups_globals_t
*cg
= _cupsGlobals();
573 /* Pointer to library globals */
575 if ((http
= cg
->http
) == NULL
)
577 _cupsSetError(IPP_INTERNAL_ERROR
, _("No active connection"), 1);
583 * Then read from the HTTP connection...
586 return (httpRead2(http
, buffer
, length
));
591 * 'cupsSendRequest()' - Send an IPP request.
593 * Use httpWrite() to write any additional data (document, PPD file, etc.)
594 * for the request, cupsGetResponse() to get the IPP response, and httpRead()
595 * to read any additional data following the response. Only one request can be
596 * sent/queued at a time.
598 * Unlike cupsDoFileRequest(), cupsDoIORequest(), and cupsDoRequest(), the
599 * request is not freed.
601 * @since CUPS 1.4/Mac OS X 10.6@
604 http_status_t
/* O - Initial HTTP status */
605 cupsSendRequest(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
606 ipp_t
*request
, /* I - IPP request */
607 const char *resource
, /* I - Resource path */
608 size_t length
) /* I - Length of data to follow or @code CUPS_LENGTH_VARIABLE@ */
610 http_status_t status
; /* Status of HTTP request */
611 int got_status
; /* Did we get the status? */
612 ipp_state_t state
; /* State of IPP processing */
613 http_status_t expect
; /* Expect: header to use */
616 DEBUG_printf(("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", "
617 "length=" CUPS_LLFMT
")", http
, request
,
618 request
? ippOpString(request
->request
.op
.operation_id
) : "?",
619 resource
, CUPS_LLCAST length
));
622 * Range check input...
625 if (!request
|| !resource
)
627 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
633 * Get the default connection as needed...
637 if ((http
= _cupsConnect()) == NULL
)
638 return (HTTP_SERVICE_UNAVAILABLE
);
642 * See if we have an auth-info attribute and are communicating over
643 * a non-local link. If so, encrypt the link so that we can pass
644 * the authentication information securely...
647 if (ippFindAttribute(request
, "auth-info", IPP_TAG_TEXT
) &&
648 !httpAddrLocalhost(http
->hostaddr
) && !http
->tls
&&
649 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
))
651 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
652 return (HTTP_SERVICE_UNAVAILABLE
);
654 #endif /* HAVE_SSL */
657 * Reconnect if the last response had a "Connection: close"...
660 if (!strcasecmp(http
->fields
[HTTP_FIELD_CONNECTION
], "close"))
661 if (httpReconnect(http
))
663 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
664 return (HTTP_SERVICE_UNAVAILABLE
);
668 * Loop until we can send the request without authorization problems.
671 expect
= HTTP_CONTINUE
;
675 DEBUG_puts("2cupsSendRequest: Setup...");
678 * Setup the HTTP variables needed...
681 httpClearFields(http
);
682 httpSetExpect(http
, expect
);
683 httpSetField(http
, HTTP_FIELD_CONTENT_TYPE
, "application/ipp");
684 httpSetLength(http
, length
);
687 if (http
->authstring
&& !strncmp(http
->authstring
, "Negotiate", 9))
690 * Do not use cached Kerberos credentials since they will look like a
694 _cupsSetNegotiateAuthString(http
);
696 #endif /* HAVE_GSSAPI */
698 httpSetField(http
, HTTP_FIELD_AUTHORIZATION
, http
->authstring
);
700 DEBUG_printf(("2cupsSendRequest: authstring=\"%s\"", http
->authstring
));
706 DEBUG_puts("2cupsSendRequest: Sending HTTP POST...");
708 if (httpPost(http
, resource
))
710 if (httpReconnect(http
))
712 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
713 return (HTTP_SERVICE_UNAVAILABLE
);
720 * Send the IPP data...
723 DEBUG_puts("2cupsSendRequest: Writing IPP request...");
725 request
->state
= IPP_IDLE
;
726 status
= HTTP_CONTINUE
;
729 while ((state
= ippWrite(http
, request
)) != IPP_DATA
)
730 if (state
== IPP_ERROR
)
732 else if (httpCheck(http
))
736 _httpUpdate(http
, &status
);
737 if (status
>= HTTP_MULTIPLE_CHOICES
)
742 * Wait up to 1 second to get the 100-continue response as needed...
747 if (expect
== HTTP_CONTINUE
)
749 DEBUG_puts("2cupsSendRequest: Waiting for 100-continue...");
751 if (httpWait(http
, 1000))
752 _httpUpdate(http
, &status
);
754 else if (httpCheck(http
))
755 _httpUpdate(http
, &status
);
758 DEBUG_printf(("2cupsSendRequest: status=%d", status
));
761 * Process the current HTTP status...
764 if (status
>= HTTP_MULTIPLE_CHOICES
)
774 case HTTP_UNAUTHORIZED
:
775 if (cupsDoAuthentication(http
, "POST", resource
))
776 return (HTTP_AUTHORIZATION_CANCELED
);
778 if (httpReconnect(http
))
780 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
781 return (HTTP_SERVICE_UNAVAILABLE
);
786 case HTTP_UPGRADE_REQUIRED
:
788 * Flush any error message, reconnect, and then upgrade with
792 if (httpReconnect(http
))
794 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
795 return (HTTP_SERVICE_UNAVAILABLE
);
798 if (httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
))
800 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
801 return (HTTP_SERVICE_UNAVAILABLE
);
804 #endif /* HAVE_SSL */
806 case HTTP_EXPECTATION_FAILED
:
808 * Don't try using the Expect: header the next time around...
811 expect
= (http_status_t
)0;
813 if (httpReconnect(http
))
815 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
816 return (HTTP_SERVICE_UNAVAILABLE
);
822 * Some other error...
832 * 'cupsWriteRequestData()' - Write additional data after an IPP request.
834 * This function is used after @link cupsSendRequest@ to provide a PPD and
835 * after @link cupsStartDocument@ to provide a document file.
837 * @since CUPS 1.4/Mac OS X 10.6@
840 http_status_t
/* O - @code HTTP_CONTINUE@ if OK or HTTP status on error */
841 cupsWriteRequestData(
842 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
843 const char *buffer
, /* I - Bytes to write */
844 size_t length
) /* I - Number of bytes to write */
846 int wused
; /* Previous bytes in buffer */
850 * Get the default connection as needed...
853 DEBUG_printf(("cupsWriteRequestData(http=%p, buffer=%p, "
854 "length=" CUPS_LLFMT
")", http
, buffer
, CUPS_LLCAST length
));
858 _cups_globals_t
*cg
= _cupsGlobals();
859 /* Pointer to library globals */
861 if ((http
= cg
->http
) == NULL
)
863 _cupsSetError(IPP_INTERNAL_ERROR
, _("No active connection"), 1);
864 DEBUG_puts("1cupsWriteRequestData: Returning HTTP_ERROR.");
870 * Then write to the HTTP connection...
875 if (httpWrite2(http
, buffer
, length
) < 0)
877 DEBUG_puts("1cupsWriteRequestData: Returning HTTP_ERROR.");
878 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(http
->error
), 0);
883 * Finally, check if we have any pending data from the server...
886 if (length
>= HTTP_MAX_BUFFER
||
887 http
->wused
< wused
||
888 (wused
> 0 && http
->wused
== length
))
891 * We've written something to the server, so check for response data...
894 if (_httpWait(http
, 0, 1))
896 http_status_t status
; /* Status from _httpUpdate */
898 _httpUpdate(http
, &status
);
899 if (status
>= HTTP_MULTIPLE_CHOICES
)
901 _cupsSetHTTPError(status
);
905 DEBUG_printf(("1cupsWriteRequestData: Returning %d.\n", status
));
910 DEBUG_puts("1cupsWriteRequestData: Returning HTTP_CONTINUE.");
911 return (HTTP_CONTINUE
);
916 * '_cupsConnect()' - Get the default server connection...
919 http_t
* /* O - HTTP connection */
922 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
926 * See if we are connected to the same server...
932 * Compare the connection hostname, port, and encryption settings to
933 * the cached defaults; these were initialized the first time we
937 if (strcmp(cg
->http
->hostname
, cg
->server
) ||
938 cg
->ipp_port
!= _httpAddrPort(cg
->http
->hostaddr
) ||
939 (cg
->http
->encryption
!= cg
->encryption
&&
940 cg
->http
->encryption
== HTTP_ENCRYPT_NEVER
))
943 * Need to close the current connection because something has changed...
952 * (Re)connect as needed...
957 if ((cg
->http
= httpConnectEncrypt(cupsServer(), ippPort(),
958 cupsEncryption())) == NULL
)
961 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, NULL
, 0);
963 _cupsSetError(IPP_SERVICE_UNAVAILABLE
,
964 _("Unable to connect to host."), 1);
969 * Return the cached connection...
977 * '_cupsSetError()' - Set the last IPP status code and status-message.
981 _cupsSetError(ipp_status_t status
, /* I - IPP status code */
982 const char *message
, /* I - status-message value */
983 int localize
) /* I - Localize the message? */
985 _cups_globals_t
*cg
; /* Global data */
988 if (!message
&& errno
)
990 message
= strerror(errno
);
995 cg
->last_error
= status
;
997 if (cg
->last_status_message
)
999 _cupsStrFree(cg
->last_status_message
);
1001 cg
->last_status_message
= NULL
;
1009 * Get the message catalog...
1012 if (!cg
->lang_default
)
1013 cg
->lang_default
= cupsLangDefault();
1015 cg
->last_status_message
= _cupsStrAlloc(_cupsLangString(cg
->lang_default
,
1019 cg
->last_status_message
= _cupsStrAlloc(message
);
1022 DEBUG_printf(("4_cupsSetError: last_error=%s, last_status_message=\"%s\"",
1023 ippErrorString(cg
->last_error
), cg
->last_status_message
));
1028 * '_cupsSetHTTPError()' - Set the last error using the HTTP status.
1032 _cupsSetHTTPError(http_status_t status
) /* I - HTTP status code */
1036 case HTTP_NOT_FOUND
:
1037 _cupsSetError(IPP_NOT_FOUND
, httpStatus(status
), 0);
1040 case HTTP_UNAUTHORIZED
:
1041 _cupsSetError(IPP_NOT_AUTHENTICATED
, httpStatus(status
), 0);
1044 case HTTP_AUTHORIZATION_CANCELED
:
1045 _cupsSetError(IPP_AUTHENTICATION_CANCELED
, httpStatus(status
), 0);
1048 case HTTP_FORBIDDEN
:
1049 _cupsSetError(IPP_FORBIDDEN
, httpStatus(status
), 0);
1052 case HTTP_BAD_REQUEST
:
1053 _cupsSetError(IPP_BAD_REQUEST
, httpStatus(status
), 0);
1056 case HTTP_REQUEST_TOO_LARGE
:
1057 _cupsSetError(IPP_REQUEST_VALUE
, httpStatus(status
), 0);
1060 case HTTP_NOT_IMPLEMENTED
:
1061 _cupsSetError(IPP_OPERATION_NOT_SUPPORTED
, httpStatus(status
), 0);
1064 case HTTP_NOT_SUPPORTED
:
1065 _cupsSetError(IPP_VERSION_NOT_SUPPORTED
, httpStatus(status
), 0);
1068 case HTTP_UPGRADE_REQUIRED
:
1069 _cupsSetError(IPP_UPGRADE_REQUIRED
, httpStatus(status
), 0);
1072 case HTTP_PKI_ERROR
:
1073 _cupsSetError(IPP_PKI_ERROR
, httpStatus(status
), 0);
1077 _cupsSetError(IPP_INTERNAL_ERROR
, httpStatus(status
), 0);
1081 DEBUG_printf(("4_cupsSetHTTPError: HTTP error %d mapped to "
1082 "IPP_SERVICE_UNAVAILABLE!", status
));
1083 _cupsSetError(IPP_SERVICE_UNAVAILABLE
, httpStatus(status
), 0);
1090 * End of "$Id: request.c 7946 2008-09-16 23:27:54Z mike $".