extern int _cupsNextDelay(int current, int *previous) _CUPS_PRIVATE;
extern void _cupsSetDefaults(void) _CUPS_INTERNAL;
extern void _cupsSetError(ipp_status_t status, const char *message, int localize) _CUPS_PRIVATE;
-extern void _cupsSetHTTPError(http_status_t status) _CUPS_INTERNAL;
+extern void _cupsSetHTTPError(http_t *http, http_status_t status) _CUPS_INTERNAL;
# ifdef HAVE_GSSAPI
extern int _cupsSetNegotiateAuthString(http_t *http, const char *method, const char *resource) _CUPS_PRIVATE;
# endif // HAVE_GSSAPI
if (status != HTTP_STATUS_OK)
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
return (cupsGetError());
}
}
else
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
httpFlush(http);
}
if (status != HTTP_STATUS_CREATED)
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
httpFlush(http);
}
// Create the socket and set options...
if ((fd = socket(addr->addr.sa_family, SOCK_STREAM, 0)) < 0)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
return (-1);
}
if (status)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
close(fd);
// Listen...
if (listen(fd, INT_MAX))
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
close(fd);
if ((http->fd = accept(fd, (struct sockaddr *)&(http->addrlist->addr), &addrlen)) < 0)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
httpClose(http);
return (NULL);
attr = ipp->current = ipp_add_attr(ipp, NULL, ipp->curtag, IPP_TAG_ZERO, 1);
if (!attr)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to allocate IPP attribute."), 1);
DEBUG_puts("1ippReadIO: unable to allocate attribute.");
goto rollback;
}
if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag, 1)) == NULL)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to allocate IPP attribute."), 1);
DEBUG_puts("1ippReadIO: unable to allocate attribute.");
goto rollback;
}
{
if ((value->unknown.data = malloc((size_t)n)) == NULL)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to allocate IPP attribute."), 1);
DEBUG_puts("1ippReadIO: Unable to allocate value");
goto rollback;
}
// Reallocate memory...
if ((temp = realloc(temp, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
{
- _cupsSetHTTPError(HTTP_STATUS_ERROR);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to reallocate IPP attribute value."), 1);
DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
return (NULL);
}
else
{
// Save the last HTTP status as a CUPS error...
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
}
// Flush any remaining data...
}
else if (status != HTTP_STATUS_NOT_MODIFIED)
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http2, status);
if (buffer[0])
unlink(buffer);
(status >= HTTP_STATUS_BAD_REQUEST && status != HTTP_STATUS_UNAUTHORIZED &&
status != HTTP_STATUS_UPGRADE_REQUIRED))
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
break;
}
httpFlush(http);
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
/*
* Then handle encryption and authentication...
{
int temp_status; /* Temporary status */
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
do
{
_httpUpdate(http, &status);
if (status >= HTTP_STATUS_MULTIPLE_CHOICES)
{
- _cupsSetHTTPError(status);
+ _cupsSetHTTPError(http, status);
do
{
*/
void
-_cupsSetHTTPError(http_status_t status) /* I - HTTP status code */
+_cupsSetHTTPError(http_t *http, /* I - HTTP connection */
+ http_status_t status) /* I - HTTP status code */
{
switch (status)
{
break;
case HTTP_STATUS_ERROR :
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
- break;
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, http->error != 0 ? strerror(http->error) : "Internal Server Error", 0);
+ break;
default :
DEBUG_printf("4_cupsSetHTTPError: HTTP error %d mapped to IPP_STATUS_ERROR_SERVICE_UNAVAILABLE!", status);