From 0678a51d3b8be8b24e475929fae11b95d2258da4 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Thu, 25 Oct 2007 19:40:05 +0000 Subject: [PATCH] Allow test server to handle binary POSTs. Tests 35, 544 545 added: binary data POSTs. --- CHANGES | 5 ++++ tests/data/Makefile.am | 3 +- tests/data/test35 | Bin 0 -> 743 bytes tests/data/test544 | 49 ++++++++++++++++++++++++++++++++ tests/data/test545 | Bin 0 -> 748 bytes tests/libtest/Makefile.am | 8 +++++- tests/libtest/lib544.c | 57 ++++++++++++++++++++++++++++++++++++++ tests/server/sws.c | 12 ++++---- 8 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 tests/data/test35 create mode 100644 tests/data/test544 create mode 100644 tests/data/test545 create mode 100644 tests/libtest/lib544.c diff --git a/CHANGES b/CHANGES index 79f3470841..586a1ecdb9 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,11 @@ Changelog +Patrick M (25 October 2007) +- Fixed test server to allow null bytes in binary posts. +_ Added tests 35, 544 & 545 to check binary data posts, both static (in place) + and dynamic (copied). + Daniel S (25 October 2007) - Michal Marek fixed the test script to be able to use valgrind even when the lib is built shared with libtool. diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 14a511bf36..f802b1ac9a 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -45,7 +45,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test706 test707 test350 test351 test352 test353 test289 test540 test354 \ test231 test1000 test1001 test1002 test1003 test1004 test1005 test1006 \ test615 test1007 test541 test1010 test1011 test1012 test542 test543 \ - test536 test1008 test1009 test2000 test2001 test2002 test2003 + test536 test1008 test1009 test2000 test2001 test2002 test2003 test35 \ + test544 test545 filecheck: @mkdir test-place; \ diff --git a/tests/data/test35 b/tests/data/test35 new file mode 100644 index 0000000000000000000000000000000000000000..0f322f9e3901f27bf854f74f2e262759fffa27a9 GIT binary patch literal 743 zcmcC1Ni8l(PApEfc_q5VnJKAUHpyU)9hVKn1Us&bl9B>0 z8+{m8!6q*;Hx=Skg#iEH5QU`7yu_kP1(3N4<(VZJ3aPnCsVOO`DGGj}K3obm`Vb8Y zHp%(9xruox5F@Sh^;JFmgF`$6tW-hX4)6~O(JxQcFHg)X(Kj|#(A5PQs0%gRAtygw zALKD(Q@xUk5-uBkxM4PFnK`KnAUkZ8P*o|}afM`L7BeVh7GpXxF%QL^3Q3hEsa!Vt zAj9lH#zTXFOIaZ-wJ0+U>c7OalGGxFl8jVvC@W+n7AqvBrsgRq6=&p^C~?`8fz^US zucRomz>X^}v^cd$*D*acuf$4E3lxkHahrmo{F40S{2V(ja2O){926R$M8M1CkzZV5 zrGODkyj+gS$*Bb;Rtj4BTD)A&`FSOv`1484OE1Z=QZO+`h=o)Zq*^H?78K-UCMT9; u=I7~G=$4n4>!#%w +# +# Server-side + + +HTTP/1.1 200 OK swsclose +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 3 + +OK + + + +# Client-side + + +http + +# tool is what to use instead of 'curl' + +lib544 + + + +HTTP POST text data using CURLOPT_COPYPOSTFIELDS + + +http://%HOSTIP:%HTTPPORT/544 + + + +# +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +POST /544 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* +Content-Length: 4 +Content-Type: application/x-www-form-urlencoded + +This + + + diff --git a/tests/data/test545 b/tests/data/test545 new file mode 100644 index 0000000000000000000000000000000000000000..66ebb61199e9df182f53441d97a597468ddbbab5 GIT binary patch literal 748 zcmcC1Ni8l(PApEf<5K2QRtQclDoZWWEzV3y<+3SCEy$^~Po*loW8;=)<_m3MKjZISQG@3gsDz zB?=|^3Z=!V3YmGuC8>!i3i)XY>dB==IqF4Rn32=2b`Y>OD zqbV%4C^M~60TeI_iD@ONMG7Suso(%r$Ver3Q&1|-$S+aivMB?r1qDw@QD%W1 zS6pauYLTvEdTL&Ym7W$ToFL*h1x5KK`N{b?c3dDwD}bD!0CEo~qItPI@{3EX6fhjh z%jKAyoLW#~rJ$v+#fuSzrbY;{kjjEoD}}^@f}G6c#FEVXJpBsY^73-swEUu6-O{3* z)V$>Ul++YnE?%yXjLc#NP>g}n2rRt8z6A$*Vjd#g{X%^dk}6A5xoq?i9cl) { - if(req->cl <= strlen(end+strlen(END_OF_HEADERS))) + if(req->cl <= req->offset - (end - req->reqbuf) - strlen(END_OF_HEADERS)) return 1; /* done */ else return 0; /* not complete yet */ @@ -456,18 +456,16 @@ int ProcessRequest(struct httprequest *req) } /* store the entire request in a file */ -void storerequest(char *reqbuf) +void storerequest(char *reqbuf, ssize_t totalsize) { int error; ssize_t written; ssize_t writeleft; - ssize_t totalsize; FILE *dump; if (reqbuf == NULL) return; - totalsize = (ssize_t)strlen(reqbuf); if (totalsize == 0) return; @@ -531,7 +529,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req) reqbuf[req->offset]=0; /* dump the request receivied so far to the external file */ - storerequest(reqbuf); + storerequest(reqbuf, req->offset); return DOCNUMBER_INTERNAL; } @@ -560,7 +558,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req) reqbuf[req->offset]=0; /* dump the request to an external file */ - storerequest(reqbuf); + storerequest(reqbuf, req->offset); return fail; /* success */ } -- GitLab