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 zc-obcZ)@8y5XSdf;O}r`^i8OvWKAhGs%hz98U2&6x_dcL>~kz;OGdiJ&9|>)C(TM< z4Fu-o=YDth=mepoTslmdu-Mi+|1BiRlr6Gs#b=Wle49>Tc?Yg@d2JlB?~*Wqta>?x z=_Ndxtyj#ZFqpfVypx*v**U~<0LFXxb!|3040d)tp;z+#yu(DPYJ^bZ zYV=VxN?BGZ_XU*u+@#bW`h@k4{PaA)f;$Hrygk3ss&bzyOF|1&Vec|j(vuN2j9g`C z#KgAO2KUISHf4XFy>Ic&# +# +# 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 zc-m!B-*1~R5Z<$;{12x@Ri$XuNtZknF{CQpma17n4Vko;O$IK(8rTS5Liz7!L)tv_ z&1ZkU`+i(NXebi~LpEU(*kW_S#xpWU7BpCwUC4r5kbp|(_;pP9O5>2NlO*Qzn>pOh zW)MArX-!sYgX}>N`j8aI&oH}#XMM7W`3&X@e{ttq?2n%b8)o?6CVQqY_+I=&w$h4F zk+(s0pu&eQj73i@;BLO9!Owgw%~dHKaG;s>g#`?~LRJvf7XDUFfV3__8fXhawt%BS zkjfB>9P}Qpvtv_Uv%tYZR?2j_Sla(X$skao!a*~{(KdlpD$#V%N-6-W6!RQ&P{*>g zjioxkYWK2<;^gltihsKg-ygqi9=5g-A38yh>8cVcAE^4AU#%_dG4`+AkT`lt_(0(u zXOCxF7g*%iGIc($#i1L|vCM6C}0b zuU^}>-d;DAXA?k`*&WMAY{Zg6nolmVUeej`UTtr>P#52ycN<7MvU|WU0s{W7nqLcl) { - 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 */ } -- 2.47.3