summaryrefslogtreecommitdiff
path: root/tests/data
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2020-03-07 11:51:00 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-03-07 23:26:00 +0100
commit1e4cb333ef632bf081045bb7b36f0736bec52708 (patch)
tree0ff5f7038008e8dc2f76dd679d135a12a7e1a9c4 /tests/data
parent96972ec1c00a142e3859efc82a06b0b810527da2 (diff)
downloadcurl-1e4cb333ef632bf081045bb7b36f0736bec52708.tar.gz
mime: do not perform more than one read in a row
Input buffer filling may delay the data sending if data reads are slow. To overcome this problem, file and callback data reads do not accumulate in buffer anymore. All other data (memory data and mime framing) are considered as fast and still concatenated in buffer. As this may highly impact performance in terms of data overhead, an early end of part data check is added to spare a read call. When encoding a part's data, an encoder may require more bytes than made available by a single read. In this case, the above rule does not apply and reads are performed until the encoder is able to deliver some data. Tests 643, 644, 645, 650 and 654 have been adapted to the output data changes, with test data size reduced to avoid the boredom of long lists of 1-byte chunks in verification data. New test 667 checks mimepost using single-byte read callback with encoder. New test 668 checks the end of part data early detection. Fixes #4826 Reported-by: MrdUkk on github
Diffstat (limited to 'tests/data')
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test64312
-rw-r--r--tests/data/test6442
-rw-r--r--tests/data/test64564
-rw-r--r--tests/data/test65012
-rw-r--r--tests/data/test65418
-rw-r--r--tests/data/test66785
-rw-r--r--tests/data/test66899
8 files changed, 277 insertions, 17 deletions
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 99052007f..4cb7a8e74 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -85,7 +85,7 @@ test626 test627 test628 test629 test630 test631 test632 test633 test634 \
test635 test636 test637 test638 test639 test640 test641 test642 \
test643 test644 test645 test646 test647 test648 test649 test650 test651 \
test652 test653 test654 test655 test656 test658 test659 test660 test661 \
-test662 test663 test664 test665 \
+test662 test663 test664 test665 test667 test668 \
test670 test671 test672 test673 \
\
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
diff --git a/tests/data/test643 b/tests/data/test643
index 0eaf22c5f..e8da2b1c4 100644
--- a/tests/data/test643
+++ b/tests/data/test643
@@ -69,18 +69,18 @@ s/boundary=------------------------[a-z0-9]*/boundary=--------------------------
POST /643 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 718
+Content-Length: 640
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
-this is what we post to the silly web server
+dummy
------------------------------
Content-Disposition: form-data; name="callbackdata"
-this is what we post to the silly web server
+dummy
------------------------------
Content-Disposition: form-data; name="filename"
@@ -99,18 +99,18 @@ blah blah
POST /643 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 732
+Content-Length: 654
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
Content-Disposition: form-data; name="sendfile alternative"; filename="file name 2"
-this is what we post to the silly web server
+dummy
------------------------------
Content-Disposition: form-data; name="callbackdata"
-this is what we post to the silly web server
+dummy
------------------------------
Content-Disposition: form-data; name="filename"
diff --git a/tests/data/test644 b/tests/data/test644
index 256d3379a..99337ae0f 100644
--- a/tests/data/test644
+++ b/tests/data/test644
@@ -44,7 +44,7 @@ s/boundary=------------------------[a-z0-9]*/boundary=--------------------------
POST /644 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 718
+Content-Length: 640
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
diff --git a/tests/data/test645 b/tests/data/test645
index 6533944b4..eeb15f994 100644
--- a/tests/data/test645
+++ b/tests/data/test645
@@ -73,16 +73,42 @@ Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------
Expect: 100-continue
-2ce
+76
------------------------------
Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
-this is what we post to the silly web server
+d
+1
+u
+1
+m
+1
+m
+1
+y
+1
+
+
+65
------------------------------
Content-Disposition: form-data; name="callbackdata"
-this is what we post to the silly web server
+
+1
+d
+1
+u
+1
+m
+1
+m
+1
+y
+1
+
+
+19a
------------------------------
Content-Disposition: form-data; name="filename"
@@ -108,16 +134,42 @@ Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------
Expect: 100-continue
-2dc
+84
------------------------------
Content-Disposition: form-data; name="sendfile alternative"; filename="file name 2"
-this is what we post to the silly web server
+d
+1
+u
+1
+m
+1
+m
+1
+y
+1
+
+
+65
------------------------------
Content-Disposition: form-data; name="callbackdata"
-this is what we post to the silly web server
+
+1
+d
+1
+u
+1
+m
+1
+m
+1
+y
+1
+
+
+19a
------------------------------
Content-Disposition: form-data; name="filename"
diff --git a/tests/data/test650 b/tests/data/test650
index 1a06064c7..03fe43816 100644
--- a/tests/data/test650
+++ b/tests/data/test650
@@ -63,7 +63,7 @@ Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------
Expect: 100-continue
-60a
+361
------------------------------
Content-Disposition: form-data; name="fieldname"
Content-Type: text/plain
@@ -89,12 +89,16 @@ This is data from a file.
Content-Disposition: attachment; filename="test650.filedata"
Content-Type: text/whatever
+
+a5
This is data from a file.
------------------------------
Content-Disposition: attachment; filename="test650.filedata"
Content-Type: text/whatever
+
+af
This is data from a file.
--------------------------------
@@ -102,6 +106,8 @@ This is data from a file.
------------------------------
Content-Disposition: form-data; name="filecontents"
+
+10f
This is data from a file.
------------------------------
@@ -112,8 +118,12 @@ Content-Disposition: form-data; name="formlength"
Content-Disposition: form-data; name="standardinput"
Content-Type: application/octet-stream
+
+16
Some data from stdin
+30
+
--------------------------------
0
diff --git a/tests/data/test654 b/tests/data/test654
index 21697e763..9d4bf45a1 100644
--- a/tests/data/test654
+++ b/tests/data/test654
@@ -81,7 +81,7 @@ Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------
Expect: 100-continue
-20c
+1af
------------------------------
Content-Disposition: form-data; name="greeting"
Content-Type: application/X-Greeting
@@ -98,7 +98,21 @@ This is data from a file
------------------------------
Content-Disposition: form-data
-this is what we post to the silly web server
+
+1
+d
+1
+u
+1
+m
+1
+m
+1
+y
+1
+
+
+30
--------------------------------
diff --git a/tests/data/test667 b/tests/data/test667
new file mode 100644
index 000000000..2a183753b
--- /dev/null
+++ b/tests/data/test667
@@ -0,0 +1,85 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+HTTP MIME POST
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello
+</data>
+<datacheck>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib667
+</tool>
+
+ <name>
+HTTP chunked mimepost using single-byte read callback with encoder
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/667
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strippart>
+s/^--------------------------[a-z0-9]*/------------------------------/
+s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
+</strippart>
+# Note that the stripping above removes 12 bytes from every occurrence of the
+# boundary string and since 5 of them are in the body contents, we see
+# (5*12) == 60 bytes less
+<protocol>
+POST /667 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Transfer-Encoding: chunked
+Content-Type: multipart/form-data; boundary=----------------------------
+Expect: 100-continue
+
+7f
+------------------------------
+Content-Disposition: form-data; name="field"
+Content-Transfer-Encoding: base64
+
+
+4
+ZHVt
+34
+bXk=
+--------------------------------
+
+0
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test668 b/tests/data/test668
new file mode 100644
index 000000000..af0a72051
--- /dev/null
+++ b/tests/data/test668
@@ -0,0 +1,99 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+HTTP MIME POST
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello
+</data>
+<datacheck>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib668
+</tool>
+
+ <name>
+HTTP mimepost early end of data detection
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/668
+</command>
+<file name="log/file668.txt">
+This is data from a file
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strippart>
+s/^--------------------------[a-z0-9]*/------------------------------/
+s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
+</strippart>
+# Note that the stripping above removes 12 bytes from every occurrence of the
+# boundary string and since 5 of them are in the body contents, we see
+# (5*12) == 60 bytes less
+<protocol>
+POST /668 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Transfer-Encoding: chunked
+Content-Type: multipart/form-data; boundary=----------------------------
+Expect: 100-continue
+
+c1
+------------------------------
+Content-Disposition: form-data; name="field1"
+
+dummy
+------------------------------
+Content-Disposition: form-data; name="field2"
+
+
+5
+dummy
+91
+
+------------------------------
+Content-Disposition: form-data; name="field3"; filename="file668.txt"
+Content-Type: text/plain
+
+
+49
+This is data from a file
+
+--------------------------------
+
+0
+
+</protocol>
+</verify>
+</testcase>