break;
}
- if (response)
+ if (response && outfile >= 0)
{
- if (outfile >= 0)
- {
- /*
- * Write trailing data to file...
- */
+ /*
+ * Write trailing data to file...
+ */
- while ((bytes = (int)httpRead2(http, buffer, sizeof(buffer))) > 0)
- if (write(outfile, buffer, bytes) < bytes)
- break;
- }
- else
- {
- /*
- * Flush any remaining data...
- */
+ while ((bytes = (int)httpRead2(http, buffer, sizeof(buffer))) > 0)
+ if (write(outfile, buffer, bytes) < bytes)
+ break;
+ }
- httpFlush(http);
- }
+ if (http->state != HTTP_WAITING)
+ {
+ /*
+ * Flush any remaining data...
+ */
+
+ httpFlush(http);
}
}
*
* Use this function to get the response for an IPP request sent using
* cupsSendDocument() or cupsSendRequest(). For requests that return
- * additional data, use httpRead() after getting a successful response.
+ * additional data, use httpRead() after getting a successful response,
+ * otherwise call httpFlush() to complete the response processing.
*
* @since CUPS 1.4/Mac OS X 10.6@
*/
response = NULL;
_cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
+ http->status = status = HTTP_ERROR;
+ http->error = EIO;
}
}
else if (status != HTTP_ERROR)
if (!cupsDoAuthentication(http, "POST", resource))
httpReconnect(http);
else
- status = HTTP_AUTHORIZATION_CANCELED;
+ http->status = status = HTTP_AUTHORIZATION_CANCELED;
}
#ifdef HAVE_SSL
if ((http = _cupsConnect()) == NULL)
return (HTTP_SERVICE_UNAVAILABLE);
+ /*
+ * If the prior request was not flushed out, do so now...
+ */
+
+ if (http->state == HTTP_GET_SEND ||
+ http->state == HTTP_POST_SEND)
+ httpFlush(http);
+ else if (http->state != HTTP_WAITING)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+
+ return (HTTP_ERROR);
+ }
+
#ifdef HAVE_SSL
/*
* See if we have an auth-info attribute and are communicating over
* Reconnect if the last response had a "Connection: close"...
*/
- if (!strcasecmp(http->fields[HTTP_FIELD_CONNECTION], "close"))
+ if (!_cups_strcasecmp(http->fields[HTTP_FIELD_CONNECTION], "close"))
if (httpReconnect(http))
{
_cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
* "replay" attack...
*/
- _cupsSetNegotiateAuthString(http);
+ _cupsSetNegotiateAuthString(http, "POST", resource);
}
#endif /* HAVE_GSSAPI */