From c5c03ac5563961cbcbcb2a1cc3e8963d0c49e154 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 8 May 2009 02:14:50 +0000 Subject: [PATCH] Fixes for non-ASCII platforms by David McCreedy --- tests/libtest/lib506.c | 2 +- tests/libtest/lib508.c | 5 +++++ tests/libtest/lib510.c | 5 +++++ tests/libtest/lib544.c | 7 +++++++ tests/libtest/lib547.c | 9 ++++++++- tests/libtest/lib552.c | 5 +++++ tests/libtest/lib553.c | 4 ++++ tests/libtest/lib554.c | 23 ++++++++++++++++++++++- tests/libtest/lib555.c | 7 +++++++ tests/libtest/lib556.c | 14 +++++++++++++- 10 files changed, 77 insertions(+), 4 deletions(-) diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 34c774e5df..823e05d3e7 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -132,7 +132,7 @@ static void *fire(void *ptr) /* build request url */ static char *suburl(const char *base, int i) { - return curl_maprintf("%s000%c", base, 48+i); + return curl_maprintf("%s%.4d", base, i); } diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index a709b80be5..6de7e7bcda 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -63,6 +63,11 @@ int test(char *URL) /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* Set the expected POST size */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 43ead09360..c890f9d45e 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -78,6 +78,11 @@ int test(char *URL) /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 7562919729..b17e64af2d 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -13,7 +13,14 @@ #include "memdebug.h" static char teststring[] = +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61" + "\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d" + "\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a"; +#else "This\0 is test binary data with an embedded NUL byte\n"; +#endif int test(char *URL) diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 8a1070f70a..a8f73eb5f3 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -16,7 +16,14 @@ #include "memdebug.h" -#define UPLOADTHIS "this is the blurb we want to upload\n" +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ +# define UPLOADTHIS "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62" \ + "\x6c\x75\x72\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20" \ + "\x74\x6f\x20\x75\x70\x6c\x6f\x61\x64\x0a" +#else +# define UPLOADTHIS "this is the blurb we want to upload\n" +#endif #ifndef LIB548 static size_t readcallback(void *ptr, diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index ff2b8c9866..ce7ca16761 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -169,6 +169,11 @@ int test(char *URL) /* Post */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* Setup read callback */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 0a6fdcbdbf..7af9e4e421 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -70,6 +70,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HEADER, 1L); diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 2999aea08a..0a7c35d54a 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -12,7 +12,15 @@ #include "memdebug.h" -static char data[]="this is what we post to the silly web server\n"; +static char data[]= +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70" + "\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20" + "\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a"; +#else + "this is what we post to the silly web server\n"; +#endif struct WriteThis { char *readptr; @@ -70,7 +78,14 @@ int test(char *URL) formrc = curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "filename", +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape + sequences for non-ASCII platforms */ + CURLFORM_COPYCONTENTS, + "\x70\x6f\x73\x74\x69\x74\x32\x2e\x63", +#else CURLFORM_COPYCONTENTS, "postit2.c", +#endif CURLFORM_END); if(formrc) @@ -80,7 +95,13 @@ int test(char *URL) formrc = curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape + sequences for non-ASCII platforms */ + CURLFORM_COPYCONTENTS, "\x73\x65\x6e\x64", +#else CURLFORM_COPYCONTENTS, "send", +#endif CURLFORM_END); if(formrc) diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 33a1a26c72..0b9d27ae00 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -93,6 +93,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII. */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, @@ -124,6 +128,9 @@ int test(char *URL) mp_timedout = TRUE; break; } +#ifdef TPF + sleep(1); /* avoid ctl-10 dump */ +#endif if (running <= 0) { fprintf(stderr, "nothing left running.\n"); break; diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index cb57f763b3..1466e40c02 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -46,8 +46,16 @@ int test(char *URL) if(!res) { /* we are connected, now get a HTTP document the raw way */ - const char *request = "GET /556 HTTP/1.2\r\n" + const char *request = +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e" + "\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a" + "\x0d\x0a"; +#else + "GET /556 HTTP/1.2\r\n" "Host: ninja\r\n\r\n"; +#endif size_t iolen; char buf[1024]; @@ -61,6 +69,10 @@ int test(char *URL) /* busy-read like crazy */ res = curl_easy_recv(curl, buf, 1024, &iolen); +#ifdef TPF + sleep(1); /* avoid ctl-10 dump */ +#endif + if(iolen) /* send received stuff to stdout */ write(STDOUT_FILENO, buf, iolen);