cups/cups-str3435.patch
2009-12-08 12:14:51 +00:00

46 lines
1.4 KiB
Diff

diff -up cups-1.4.2/cups/util.c.str3435 cups-1.4.2/cups/util.c
--- cups-1.4.2/cups/util.c.str3435 2009-06-22 21:44:34.000000000 +0100
+++ cups-1.4.2/cups/util.c 2009-12-08 12:11:38.647375446 +0000
@@ -1511,12 +1511,36 @@ cupsPrintFiles2(
return (0);
}
- status = cupsStartDocument(http, name, job_id, docname, format,
- i == (num_files - 1));
+ do
+ {
+ cupsFileRewind(fp);
+
+ status = cupsStartDocument(http, name, job_id, docname, format,
+ i == (num_files - 1));
+
+ while (status == HTTP_CONTINUE &&
+ (bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
+ status = cupsWriteRequestData(http, buffer, bytes);
+
+ if (status == HTTP_UNAUTHORIZED)
+ {
+ char resource[1024]; /* Printer resource */
- while (status == HTTP_CONTINUE &&
- (bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
- status = cupsWriteRequestData(http, buffer, bytes);
+ snprintf(resource, sizeof(resource), "/printers/%s", name);
+
+ if (!cupsDoAuthentication(http, "POST", resource))
+ {
+ if (httpReconnect(http))
+ {
+ _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
+ return (0);
+ }
+ }
+ else
+ status = HTTP_AUTHORIZATION_CANCELED;
+ }
+ }
+ while (status == HTTP_UNAUTHORIZED);
cupsFileClose(fp);