aboutsummaryrefslogtreecommitdiff
path: root/lib/http_digest.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-01-14 14:57:51 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-01-14 14:57:51 +0000
commit0fb5a65a58130da7882f0a8d396e24b95c25064f (patch)
treed6c39e8a01c8815f724c47005d7a7409fe678ab7 /lib/http_digest.c
parentc8afb02b4cf51038e84edec13fb52a6ad149d044 (diff)
- David McCreedy provided libcurl changes for doing HTTP communication on
non-ASCII platforms. It does add some complexity, most notably with more #ifdefs, but I want to see this supported added and I can't see how we can add it without the extra stuff added.
Diffstat (limited to 'lib/http_digest.c')
-rw-r--r--lib/http_digest.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/http_digest.c b/lib/http_digest.c
index e5d8baae5..c223784f9 100644
--- a/lib/http_digest.c
+++ b/lib/http_digest.c
@@ -39,6 +39,7 @@
#include "strtok.h"
#include "url.h" /* for Curl_safefree() */
#include "memory.h"
+#include "easyif.h" /* included for Curl_convert_... prototypes */
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -234,6 +235,21 @@ CURLcode Curl_output_digest(struct connectdata *conn,
struct SessionHandle *data = conn->data;
struct digestdata *d;
+#ifdef CURL_DOES_CONVERSIONS
+ CURLcode rc;
+/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines.
+ It converts digest text to ASCII so the MD5 will be correct for
+ what ultimately goes over the network.
+*/
+#define CURL_OUTPUT_DIGEST_CONV(a, b) \
+ rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
+ if (rc != CURLE_OK) { \
+ free(b); \
+ return rc; \
+ }
+#else
+#define CURL_OUTPUT_DIGEST_CONV(a, b)
+#endif /* CURL_DOES_CONVERSIONS */
if(proxy) {
d = &data->state.proxydigest;
@@ -291,6 +307,8 @@ CURLcode Curl_output_digest(struct connectdata *conn,
aprintf("%s:%s:%s", userp, d->realm, passwdp);
if(!md5this)
return CURLE_OUT_OF_MEMORY;
+
+ CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
Curl_md5it(md5buf, md5this);
free(md5this); /* free this again */
@@ -305,6 +323,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
tmp = aprintf("%s:%s:%s", ha1, d->nonce, d->cnonce);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
+ CURL_OUTPUT_DIGEST_CONV(data, tmp); /* convert on non-ASCII machines */
Curl_md5it(md5buf, (unsigned char *)tmp);
free(tmp); /* free this again */
md5_to_ascii(md5buf, ha1);
@@ -334,6 +353,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
entity-body here */
/* TODO: Append H(entity-body)*/
}
+ CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
Curl_md5it(md5buf, md5this);
free(md5this); /* free this again */
md5_to_ascii(md5buf, ha2);
@@ -357,6 +377,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
if(!md5this)
return CURLE_OUT_OF_MEMORY;
+ CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
Curl_md5it(md5buf, md5this);
free(md5this); /* free this again */
md5_to_ascii(md5buf, request_digest);