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 79f347084..586a1ecdb 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 14a511bf3..f802b1ac9 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 zcmb7CQES^U5Z?2F|HF~dmoP`knlfrMv(mvb+BKnd_c&1Ob1Y^{M!wd~zn^3$?Mj~t z0&&vaci;EjNv4i-)lmx4QCsi*T_{#5tg>t)7PAF@p3iZ8gfsa4 z&+*1S`i#XK7t3UMp7`7!zcRQZ_ed_mfF5^4AWHR@0JgOn4}cV7Cn*k{;Uiwwnv5^e z1%b?mz%v>VQmB|)Uv>;p8r68_fhum+cNuQAQEra`7kkYWQnRI^paO61uK}eP3sB~^ zX_P5O$V7;fl`sFfNlpURW__E9oMC_ z&#CoaQ!$O;(i#r)yC$>aD#7KKm$z)+`n^$YTkBl0wnjX~ec#8Wbxr)>YBIU?lZqgE Qzf~_1q +# +# 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 zcmZWn-*4J55Z<#T{)ZE&s)UvrI(TU0MXKmFs+G>q6XO%p!7n!@#D z0`UXb)@G%#$nGRz2x)Qn3X>anG%pS@oxpS!&Tc}7{q;L#{f-d)=D>Cf`A+^vwlJDd zQ?Nq4ry_)JjKvR3aKGQt;O~4K%|)p^u&0@Ig#+}nB32O94t^>}K*p4yEVP9rSHQs{ zC~XO44rT|J*`X;fneecPm1;Ym&0T+AG7wr;&K|EBl6alMR%zKBp;c4>R$I(-%t0T@ z(hXL64~xyyDo)aWi#Yk?8-CvZSlzANAl^>`k(sKJI`655oL?**>^=!E{E{SoN_kJ= z11I=NWf#*kHfnc-E*QBZY=8>v4242k*dl5e+QQI~374nCdV8o*b;SN|oH4=e-WeEP zjlEC(yQmvOCi50_Dm?`_1wCL(V=07BLcl) { - 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.40.0