From f277124a0f78327f6a973518c073d6a9a458326b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Dec 2007 21:48:52 +0000 Subject: [PATCH] In an attempt to repeat the problem in bug report #1850730 (http://curl.haxx.se/bug/view.cgi?id=1850730) I wrote up test case 552. The test is doing a 70K POST with a read callback and an ioctl callback over a proxy requiring Digest auth. The test case code is more or less identical to the test recipe code provided by Spacen Jasset (who submitted the bug report). --- CHANGES | 8 ++ tests/data/Makefile.am | 2 +- tests/data/test552 | Bin 0 -> 143252 bytes tests/libtest/Makefile.am | 3 +- tests/libtest/lib552.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 tests/data/test552 create mode 100644 tests/libtest/lib552.c diff --git a/CHANGES b/CHANGES index 34a8fc2..f02e380 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,14 @@ Changelog +Daniel S (26 Dec 2007) +- In an attempt to repeat the problem in bug report #1850730 + (http://curl.haxx.se/bug/view.cgi?id=1850730) I wrote up test case 552. The + test is doing a 70K POST with a read callback and an ioctl callback over a + proxy requiring Digest auth. The test case code is more or less identical to + the test recipe code provided by Spacen Jasset (who submitted the bug + report). + Daniel S (25 Dec 2007) - Gary Maxwell filed bug report #1856628 (http://curl.haxx.se/bug/view.cgi?id=1856628) and provided a fix for the diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 57081c3..4c214bc 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -47,7 +47,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test615 test1007 test541 test1010 test1011 test1012 test542 test543 \ test536 test1008 test1009 test2000 test2001 test2002 test2003 test35 \ test544 test545 test2004 test546 test1013 test1014 test1015 \ - test547 test548 test549 test550 test551 + test547 test548 test549 test550 test551 test552 filecheck: @mkdir test-place; \ diff --git a/tests/data/test552 b/tests/data/test552 new file mode 100644 index 0000000000000000000000000000000000000000..9978a2b77a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pt zjWkBJHPXIZw3S0SuL^$p^0j-sw4+Ho zhedk(Ve!ND;$s+|IUm0d!ym)*M#>+-wM3Jqrcnj{Iw}F zU-n+-?x|?i@y;I$k$Iwo3O^Rplf0JEJ6@AhF3><>HMyflw{KdkN6l*zA=O-w#fXUWEKRLiA# zlsNujK38mvKz61slaubt{x>^W z6(+A_x0ZSw=~a9*UL79}mtU`rkH+!Q(P*Vtq4&R1-<7CJ2iQ(<2JqCYhCzZnmov<^10Qy^{;fkvD=9n59Iaw@nT=- ziHeFMP2wgwgGYb2+xcr#W`13!I**OawBwyW7Bc)q4F>~1mNApOmeD(&o3ug|Vn817 ze8uw>5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X z5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfI zA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnY zArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X z5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfI zA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnY zArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X z5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+WfIA|VnYArc}X5+dRMRYGqX6s55yHt9@` SA9R_l_wL9FH*r+ynfDvM=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { + i+=(c+3-width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +static +int my_trace(CURL *handle, curl_infotype type, + unsigned char *data, size_t size, + void *userp) +{ + struct data *config = (struct data *)userp; + const char *text; + (void)handle; /* prevent compiler warning */ + + switch (type) { + case CURLINFO_TEXT: + fprintf(stderr, "== Info: %s", data); + default: /* in case a new one is introduced to shock us */ + return 0; + + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "=> Send SSL data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "<= Recv SSL data"; + break; + } + + dump(text, stderr, data, size, config->trace_ascii); + return 0; +} + + +static size_t current_offset = 0; +char data[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t available = sizeof data - current_offset; /* What we have to give */ + size_t given = amount < available ? amount : available; /* What is given */ + (void)stream; + memcpy(ptr, data + current_offset, given); + current_offset += given; + return given; +} + + +static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + printf("%.*s", size * nmemb, (char *)ptr); + (void)stream; + return size * nmemb; +} + + +static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp) +{ + (void)clientp; + if (cmd == CURLIOCMD_RESTARTREAD ) { + printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n"); + printf("APPLICATION: ** REWINDING! **\n"); + current_offset = 0; + return CURLIOE_OK; + } + (void)handle; + return CURLIOE_UNKNOWNCMD; +} + + + +int test(char *URL) +{ + CURL *curl; + CURLcode res; + struct data config; + size_t i; + char fill[] = "test data"; + + config.trace_ascii = 1; /* enable ascii tracing */ + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* setup repeated data string */ + for (i=0; i < sizeof data; ++i) + data[i] = fill[i % sizeof fill]; + + /* Post */ + curl_easy_setopt(curl, CURLOPT_POST, 1); + + /* Setup read callback */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof data); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* Write callback */ + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + + /* Ioctl function */ + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); + + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + + res = curl_easy_perform(curl); + fprintf(stderr, "curl_east_perform = %d\n", res); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} -- 2.7.4