http_status = cupsSendRequest(http, request, resource, length);
if (http_status == HTTP_CONTINUE && request->state == IPP_DATA)
{
+ if (compression && strcmp(compression, "none"))
+ httpSetField(http, HTTP_FIELD_CONTENT_ENCODING, compression);
+
if (num_files == 1)
{
if ((fd = open(files[0], O_RDONLY)) < 0)
{
fprintf(stderr, "DEBUG: Read %d bytes...\n", (int)bytes);
- if (cupsWriteRequestData(http, buffer, bytes) != HTTP_CONTINUE)
+ if ((http_status = cupsWriteRequestData(http, buffer, bytes))
+ != HTTP_CONTINUE)
break;
}
else if (bytes == 0 || (errno != EINTR && errno != EAGAIN))
}
}
+ if (http_status == HTTP_ERROR)
+ fprintf(stderr, "DEBUG: Error writing document data for "
+ "Print-Job: %s\n", strerror(httpError(http)));
+
if (num_files == 1)
close(fd);
}
close(fd);
}
+ if (http_status == HTTP_ERROR)
+ fprintf(stderr, "DEBUG: Error writing document data for "
+ "Send-Document: %s\n", strerror(httpError(http)));
+
ippDelete(cupsGetResponse(http, resource));
ippDelete(request);
*/
#define _httpAddrFamily(addrp) (addrp)->addr.sa_family
-extern int _httpAddrPort(http_addr_t *addr)
- _CUPS_DEPRECATED_MSG("Use httpAddrPort "
- "instead.");
extern void _httpAddrSetPort(http_addr_t *addr, int port);
extern char *_httpAssembleUUID(const char *server, int port,
const char *name, int number,
extern char *_httpEncodeURI(char *dst, const char *src,
size_t dstsize);
extern void _httpFreeCredentials(http_tls_credentials_t credentials);
-extern ssize_t _httpPeek(http_t *http, char *buffer, size_t length)
- _CUPS_DEPRECATED_MSG("Use httpPeek instead.");
extern const char *_httpResolveURI(const char *uri, char *resolved_uri,
size_t resolved_size, int options,
int (*cb)(void *context),
* Didn't get the data back, so close the current connection.
*/
+#ifdef HAVE_LIBZ
+ if (http->coding)
+ http_content_coding_finish(http);
+#endif /* HAVE_LIBZ */
+
DEBUG_puts("1httpFlush: Setting state to HTTP_STATE_WAITING and closing.");
http->state = HTTP_STATE_WAITING;
if (http->data_encoding == HTTP_ENCODING_CHUNKED)
httpGets(len, sizeof(len), http);
+#ifdef HAVE_LIBZ
+ if (http->coding)
+ http_content_coding_finish(http);
+#endif /* HAVE_LIBZ */
+
if (http->state == HTTP_STATE_POST_RECV)
http->state ++;
else
return (bytes);
}
-ssize_t /* O - Number of bytes copied */
-_httpPeek(http_t *http, /* I - Connection to server */
- char *buffer, /* I - Buffer for data */
- size_t length) /* I - Maximum number of bytes */
-{
- /* TODO: Remove in CUPS 1.8 */
- return (httpPeek(http, buffer, length));
-}
-
/*
* 'httpPost()' - Send a POST request to the server.
if (http->data_encoding == HTTP_ENCODING_CHUNKED &&
http->data_remaining <= 0)
{
- DEBUG_puts("2httpRead2: Getting chunk length...");
-
- if (httpGets(len, sizeof(len), http) == NULL)
+ if (!httpGets(len, sizeof(len), http))
{
- DEBUG_puts("1httpRead2: Could not get length!");
+ DEBUG_puts("1httpRead2: Could not get chunk length.");
return (0);
}
+ if (!len[0])
+ {
+ DEBUG_puts("1httpRead2: Blank chunk length, trying again...");
+ if (!httpGets(len, sizeof(len), http))
+ {
+ DEBUG_puts("1httpRead2: Could not get chunk length.");
+ return (0);
+ }
+ }
+
http->data_remaining = strtoll(len, NULL, 16);
+
if (http->data_remaining < 0)
{
- DEBUG_puts("1httpRead2: Negative chunk length!");
+ DEBUG_printf(("1httpRead2: Negative chunk length \"%s\" (" CUPS_LLFMT ")",
+ len, CUPS_LLCAST http->data_remaining));
return (0);
}
+
+ DEBUG_printf(("2httpRead2: Got chunk length \"%s\" (" CUPS_LLFMT ")", len,
+ CUPS_LLCAST http->data_remaining));
}
DEBUG_printf(("2httpRead2: data_remaining=" CUPS_LLFMT ", used=%d",
return (0);
}
- if (http->data_remaining == 0)
+ if (http->data_remaining <= 0)
{
if (http->data_encoding == HTTP_ENCODING_CHUNKED)
+ {
+ DEBUG_puts("1httpRead2: Reading trailing line for chunk.");
httpGets(len, sizeof(len), http);
+ }
else
{
#ifdef HAVE_LIBZ
if (http->state == HTTP_STATE_POST_RECV)
{
+#ifdef HAVE_LIBZ
+ if (http->coding)
+ http_content_coding_finish(http);
+#endif /* HAVE_LIBZ */
+
http->state ++;
DEBUG_printf(("2httpWrite2: Changed state to %s.",