aboutsummaryrefslogtreecommitdiffstats
path: root/cups/request.c
diff options
context:
space:
mode:
Diffstat (limited to 'cups/request.c')
-rw-r--r--cups/request.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/cups/request.c b/cups/request.c
index efbc06eb..a4e4b905 100644
--- a/cups/request.c
+++ b/cups/request.c
@@ -20,11 +20,11 @@
#include "cups-private.h"
#include <fcntl.h>
#include <sys/stat.h>
-#if defined(WIN32) || defined(__EMX__)
+#if defined(_WIN32) || defined(__EMX__)
# include <io.h>
#else
# include <unistd.h>
-#endif /* WIN32 || __EMX__ */
+#endif /* _WIN32 || __EMX__ */
#ifndef O_BINARY
# define O_BINARY 0
#endif /* O_BINARY */
@@ -156,11 +156,11 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
return (NULL);
}
-#ifdef WIN32
+#ifdef _WIN32
if (fileinfo.st_mode & _S_IFDIR)
#else
if (S_ISDIR(fileinfo.st_mode))
-#endif /* WIN32 */
+#endif /* _WIN32 */
{
/*
* Can't send a directory...
@@ -172,11 +172,11 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
return (NULL);
}
-#ifndef WIN32
+#ifndef _WIN32
if (!S_ISREG(fileinfo.st_mode))
length = 0; /* Chunk when piping */
else
-#endif /* !WIN32 */
+#endif /* !_WIN32 */
length = ippLength(request) + (size_t)fileinfo.st_size;
}
else
@@ -215,9 +215,9 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
* Send the file with the request...
*/
-#ifndef WIN32
+#ifndef _WIN32
if (S_ISREG(fileinfo.st_mode))
-#endif /* WIN32 */
+#endif /* _WIN32 */
lseek(infile, 0, SEEK_SET);
while ((bytes = read(infile, buffer, sizeof(buffer))) > 0)
@@ -591,7 +591,8 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
int got_status; /* Did we get the status? */
ipp_state_t state; /* State of IPP processing */
http_status_t expect; /* Expect: header to use */
- char date[256]; /* Date: header value */
+ char date[256]; /* Date: header value */
+ int digest; /* Are we using Digest authentication? */
DEBUG_printf(("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", length=" CUPS_LLFMT ")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, CUPS_LLCAST length));
@@ -683,6 +684,17 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
httpSetField(http, HTTP_FIELD_DATE, httpGetDateString2(time(NULL), date, (int)sizeof(date)));
httpSetLength(http, length);
+ digest = http->authstring && !strncmp(http->authstring, "Digest ", 7);
+
+ if (digest)
+ {
+ /*
+ * Update the Digest authentication string...
+ */
+
+ _httpSetDigestAuthString(http, http->nextnonce, "POST", resource);
+ }
+
#ifdef HAVE_GSSAPI
if (http->authstring && !strncmp(http->authstring, "Negotiate", 9))
{
@@ -767,9 +779,9 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
* Wait up to 1 second to get the 100-continue response as needed...
*/
- if (!got_status)
+ if (!got_status || (digest && status == HTTP_STATUS_CONTINUE))
{
- if (expect == HTTP_STATUS_CONTINUE)
+ if (expect == HTTP_STATUS_CONTINUE || digest)
{
DEBUG_puts("2cupsSendRequest: Waiting for 100-continue...");
@@ -1016,13 +1028,13 @@ _cupsConnect(void)
char ch; /* Connection check byte */
ssize_t n; /* Number of bytes */
-#ifdef WIN32
+#ifdef _WIN32
if ((n = recv(cg->http->fd, &ch, 1, MSG_PEEK)) == 0 ||
(n < 0 && WSAGetLastError() != WSAEWOULDBLOCK))
#else
if ((n = recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT)) == 0 ||
(n < 0 && errno != EWOULDBLOCK))
-#endif /* WIN32 */
+#endif /* _WIN32 */
{
/*
* Nope, close the connection...