# endif
#endif
-#ifdef WINDOWS
-# include <winsock.h>
-#else
-# include <netdb.h> /* for h_errno */
-#endif
-
#include "wget.h"
#include "utils.h"
#include "url.h"
#ifndef errno
extern int errno;
#endif
-#ifndef h_errno
-# ifndef __CYGWIN__
-extern int h_errno;
-# endif
-#endif
\f
static int cookies_loaded_p;
DEBUGP (("Registered fd %d for persistent reuse.\n", fd));
}
+#ifdef HAVE_SSL
+# define SHUTDOWN_SSL(ssl) do { \
+ if (ssl) \
+ shutdown_ssl (ssl); \
+} while (0)
+#else
+# define SHUTDOWN_SSL(ssl)
+#endif
+
/* Return non-zero if a persistent connection is available for
connecting to HOST:PORT. */
let's invalidate the persistent connection before returning
0. */
CLOSE (pc_last_fd);
+#ifdef HAVE_SSL
+ SHUTDOWN_SSL (pc_last_ssl);
+ pc_last_ssl = NULL;
+#endif
invalidate_persistent ();
return 0;
}
return 1;
}
-#ifdef HAVE_SSL
-# define SHUTDOWN_SSL(ssl) do { \
- if (ssl) \
- shutdown_ssl (ssl); \
-} while (0)
-#else
-# define SHUTDOWN_SSL(ssl)
-#endif
-
/* The idea behind these two CLOSE macros is to distinguish between
two cases: one when the job we've been doing is finished, and we
want to close the connection and leave, and two when something is
}
else
{
+ /* Use the full path, i.e. one that includes the leading
+ slash and the query string, but is independent of proxy
+ setting. */
+ char *pth = url_full_path (u);
wwwauth = create_authorization_line (authenticate_h, user, passwd,
- command, u->path);
+ command, pth);
+ xfree (pth);
}
}
if (proxy)
full_path = xstrdup (u->url);
else
+ /* Use the full path, i.e. one that includes the leading slash and
+ the query string. E.g. if u->path is "foo/bar" and u->query is
+ "param=value", full_path will be "/foo/bar?param=value". */
full_path = url_full_path (u);
/* Allocate the memory for the request. */
/* Send the request to server. */
#ifdef HAVE_SSL
- if (u->scheme == SCHEME_HTTPS)
+ if (conn->scheme == SCHEME_HTTPS)
num_written = ssl_iwrite (ssl, request, strlen (request));
else
#endif /* HAVE_SSL */
/* Before reading anything, initialize the rbuf. */
rbuf_initialize (&rbuf, sock);
#ifdef HAVE_SSL
- if (u->scheme == SCHEME_HTTPS)
+ if (conn->scheme == SCHEME_HTTPS)
rbuf.ssl = ssl;
else
rbuf.ssl = NULL;
/* Take the line apart to find the challenge, and compose a digest
authorization header. See RFC2069 section 2.1.2. */
-char *
+static char *
digest_authentication_encode (const char *au, const char *user,
const char *passwd, const char *method,
const char *path)
/* A1BUF = H(user ":" realm ":" password) */
gen_md5_init (ctx);
- gen_md5_update (user, strlen (user), ctx);
- gen_md5_update (":", 1, ctx);
- gen_md5_update (realm, strlen (realm), ctx);
- gen_md5_update (":", 1, ctx);
- gen_md5_update (passwd, strlen (passwd), ctx);
+ gen_md5_update ((unsigned char *)user, strlen (user), ctx);
+ gen_md5_update ((unsigned char *)":", 1, ctx);
+ gen_md5_update ((unsigned char *)realm, strlen (realm), ctx);
+ gen_md5_update ((unsigned char *)":", 1, ctx);
+ gen_md5_update ((unsigned char *)passwd, strlen (passwd), ctx);
gen_md5_finish (ctx, hash);
dump_hash (a1buf, hash);
/* A2BUF = H(method ":" path) */
gen_md5_init (ctx);
- gen_md5_update (method, strlen (method), ctx);
- gen_md5_update (":", 1, ctx);
- gen_md5_update (path, strlen (path), ctx);
+ gen_md5_update ((unsigned char *)method, strlen (method), ctx);
+ gen_md5_update ((unsigned char *)":", 1, ctx);
+ gen_md5_update ((unsigned char *)path, strlen (path), ctx);
gen_md5_finish (ctx, hash);
dump_hash (a2buf, hash);
/* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" A2BUF) */
gen_md5_init (ctx);
gen_md5_update (a1buf, MD5_HASHLEN * 2, ctx);
- gen_md5_update (":", 1, ctx);
- gen_md5_update (nonce, strlen (nonce), ctx);
- gen_md5_update (":", 1, ctx);
+ gen_md5_update ((unsigned char *)":", 1, ctx);
+ gen_md5_update ((unsigned char *)nonce, strlen (nonce), ctx);
+ gen_md5_update ((unsigned char *)":", 1, ctx);
gen_md5_update (a2buf, MD5_HASHLEN * 2, ctx);
gen_md5_finish (ctx, hash);
dump_hash (response_digest, hash);