Fixes for non-ASCII platforms by David McCreedy

This commit is contained in:
Yang Tse 2009-05-08 02:14:50 +00:00
parent 6ca321ca75
commit c5c03ac556
10 changed files with 77 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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);