diff --git a/.gitignore b/.gitignore index 7c7ccb2c..9c668d77 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ # re-ignores: add here what you want to be ignored again test/tmp +test-node/tmp # !src/*.js # !src/*.ts diff --git a/a.js b/a.js new file mode 100644 index 00000000..64c60d9a --- /dev/null +++ b/a.js @@ -0,0 +1,8 @@ +const textDecoder = new TextDecoder(); +/* works with +Uint8Array, Uint16Array, Uint32Array, +Int8Array, Int16Array, Int32Array, ArrayBuffer */ +const stringFromArrayBuffer = function (arrayBufferOrView) { + return textDecoder.decode(arrayBufferOrView); +}; +console.log(stringFromArrayBuffer(new Uint8Array([45, 45, 45, 45, 45, 45, 84, 76, 86, 48, 83, 114, 75, 68, 52, 122, 49, 84, 82, 120, 82, 104, 65, 80, 85, 118, 90, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 68, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 58, 32, 102, 111, 114, 109, 45, 100, 97, 116, 97, 59, 32, 110, 97, 109, 101, 61, 34, 117, 112, 108, 111, 97, 100, 34, 59, 32, 102, 105, 108, 101, 110, 97, 109, 101, 61, 34, 112, 108, 97, 105, 110, 46, 116, 120, 116, 34, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 116, 101, 120, 116, 47, 112, 108, 97, 105, 110, 13, 10, 13, 10, 73, 32, 97, 109, 32, 97, 32, 115, 105, 109, 112, 108, 101, 32, 112, 108, 97, 105, 110, 32, 116, 101, 120, 116, 32, 102, 105, 108, 101, 13, 10, 13, 10, 45, 45, 45, 45, 45, 45, 84, 76, 86, 48, 83, 114, 75, 68, 52, 122, 49, 84, 82, 120, 82, 104, 65, 80, 85, 118, 90, 13, 10]))) \ No newline at end of file diff --git a/package.json b/package.json index 1e8b148f..2a218729 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,8 @@ "test-specific": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=test/standalone/keep-alive-error.test.js", "test": "npm run test-jest && npm run test-node", "test-jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=test/ --coverage", - "test-node": "node --test test-node/", + "test-node": "node --test \"test-node/**/*.test.js\" --test-concurrency 1", + "test-node2": "node --test \"test-node/**/integration/**/*.test.js\" --test-concurrency 1", "pretest:ci": "yarn run pretest", "test:ci": "node --experimental-vm-modules node_modules/.bin/nyc jest --testPathPattern=test/ --coverage && node --experimental-vm-modules node_modules/.bin/nyc node --test test-node/" }, diff --git a/src/Formidable.js b/src/Formidable.js index 7cc722bf..eed014a8 100644 --- a/src/Formidable.js +++ b/src/Formidable.js @@ -492,11 +492,11 @@ class IncomingForm extends EventEmitter { this.req = null; this.error = err; - this.emit(eventName, err); - this.openedFiles.forEach((file) => { file.destroy(); }); + this.emit(eventName, err); + } _parseContentLength() { diff --git a/test/fixture/file/beta-sticker-1.png b/test-node/fixture/file/beta-sticker-1.png similarity index 100% rename from test/fixture/file/beta-sticker-1.png rename to test-node/fixture/file/beta-sticker-1.png diff --git a/test/fixture/file/binaryfile.tar.gz b/test-node/fixture/file/binaryfile.tar.gz similarity index 100% rename from test/fixture/file/binaryfile.tar.gz rename to test-node/fixture/file/binaryfile.tar.gz diff --git a/test/fixture/file/blank.gif b/test-node/fixture/file/blank.gif old mode 100755 new mode 100644 similarity index 100% rename from test/fixture/file/blank.gif rename to test-node/fixture/file/blank.gif diff --git a/test/fixture/file/funkyfilename.txt b/test-node/fixture/file/funkyfilename.txt similarity index 100% rename from test/fixture/file/funkyfilename.txt rename to test-node/fixture/file/funkyfilename.txt diff --git a/test/fixture/file/menu_separator.png b/test-node/fixture/file/menu_separator.png similarity index 100% rename from test/fixture/file/menu_separator.png rename to test-node/fixture/file/menu_separator.png diff --git a/test/fixture/file/plain.txt b/test-node/fixture/file/plain.txt similarity index 100% rename from test/fixture/file/plain.txt rename to test-node/fixture/file/plain.txt diff --git a/test-node/fixture/file/readme.md b/test-node/fixture/file/readme.md new file mode 100644 index 00000000..52eaae4d --- /dev/null +++ b/test-node/fixture/file/readme.md @@ -0,0 +1 @@ +These are the original files that were used to create the files inside http which are like http request header + body in 1 file. diff --git a/test/fixture/file/second-plaintext.txt b/test-node/fixture/file/second-plaintext.txt similarity index 100% rename from test/fixture/file/second-plaintext.txt rename to test-node/fixture/file/second-plaintext.txt diff --git a/test/fixture/http/encoding/beta-sticker-1.png.http b/test-node/fixture/http/encoding/beta-sticker-1.png.http similarity index 99% rename from test/fixture/http/encoding/beta-sticker-1.png.http rename to test-node/fixture/http/encoding/beta-sticker-1.png.http index 833b83ca..7bfc6dcc 100644 --- a/test/fixture/http/encoding/beta-sticker-1.png.http +++ b/test-node/fixture/http/encoding/beta-sticker-1.png.http @@ -1,12 +1,12 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Length: 2483 - ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Disposition: form-data; name="sticker"; filename="beta-sticker-1.png" -Content-Type: image/png -Content-Transfer-Encoding: base64 - -iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABh5JREFUeNrMmHtIHEcYwGfv5SNwaovxEanEiJKqlYCCTRo1f0SvDeof1legEcE/YttQaNOiaQjYFFtpKaJILZU8SCRUWqlJGpoWepGLTXqUEnzFxCrnK9DEelbvvPOe/WacuY7r7HmGFjrwsbNzt7u//V7zfYvQ/2xI/9K1/NyvMP9PgCTuGmmL6/0ckD9UOGmbIExUsqMkAPHJjv5QwKRtgKioqDlh5+w/7IFeCuLlxCeA2zQ0IcCwh2qoaLH09fUdTElJ2e/1elU+n0/y+9fvPz4+fvfYsWN3YOoBcXPiocLghD4mBYHhQTCErq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n04ncbjfRGAMV5ZlQxvDw8E+yYi1Q3qpleYjUQlNTU5aysrJqgNBhIAwGVSDCkFj48BVFULA1eCl7XV3dx1CKYK3YqKnY7u9Ti2royclJ76FDh1YhxefgsoFpCIOtra0RuGBQwYbRaLzc1dVlpjA2ZiqmKbWsDAmEYU9Pz8Tg4OCNoqKixNTU1BQostDq6iqBcrlcRBiYfEff1KBR+OnpabPBYOikWlnhtOOWm0zUffpnZ2ednZ2dJtCYMTs7+xkA2x0eHk6gsMYwFPYr/EC1Wo2LMEWzWa1WC1QRZ8FUVgpj42ohD3umWqHjRFxf5RkZGVkCNQ9CcTWQn5+flpSUtBOiMKAt7Fek/FSAmpmZMVdVVZ0dGxv7g4PhteMVlbBIofv0sh4Lbmhtb2+/Cbv1eFpaWmJCQsJODMO0hGGgUghAAay9v7//i5KSki9lmmG+4+Jg/MHaIH6f0dCkqaNFFc5VkViam5v319TUNEDdvRubEGsNYHGqsAwMDFxta2u7DdpdpA+3c+LgWiHfVkCiFnpDw0iLqwgqO6BVKoPo00K6WIDsOzE6OrpE395FzeLgxMn5jVe0dYTa26s5jfFg4VR0nAuwNtrFda1rgmToD6VzVWq3eTPyYAxOwwH5gvT2PiWY7X4fUgJTywp1fivyyL6E+Lb6XvQ0X9AkBeeXZED+p/k+9LcAAwAXm3hBLzoZPAAAAABJRU5ErkJggg== ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 2483 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="sticker"; filename="beta-sticker-1.png" +Content-Type: image/png +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAACQAA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+p/k+9LcAAwAXm3hBLzoZPAAAAABJRU5ErkJggg== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/test/fixture/http/encoding/binaryfile.tar.gz.http b/test-node/fixture/http/encoding/binaryfile.tar.gz.http similarity index 98% rename from test/fixture/http/encoding/binaryfile.tar.gz.http rename to test-node/fixture/http/encoding/binaryfile.tar.gz.http index 4f4fadb0..28b1d0e6 100644 --- a/test/fixture/http/encoding/binaryfile.tar.gz.http +++ b/test-node/fixture/http/encoding/binaryfile.tar.gz.http @@ -1,12 +1,12 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Length: 676 - ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Disposition: form-data; name="file"; filename="binaryfile.tar.gz" -Content-Type: application/x-gzip -Content-Transfer-Encoding: base64 - -H4sIAGiNIU8AA+3R0W6CMBQGYK59iobLZantRDG73osUOGqnFNJWM2N897UghG1ZdmWWLf93U/jP4bRAq8q92hJ/dY1J7kQEqyyLq8yXYrp2ltkqkTKXYiEykYc++ZTLVcLEvQ40dXReWcYSV1pdnL/v+6n+R11mjKVG1ZQ+s3TT2FpXqjhQ+hjzE1mnGxNLkgu+7tOKWjIVmVKTC6XL9ZaeXj4VQhwKWzL+cI4zwgQuuhkh3mhTad/Hkssh3im3027X54JnQ360R/M19OT8kC7SEN7Ooi2VvrEfznHQRWzl83gxttZKmzGehzPRW/+W8X+3fvL8sFet9sS6m3EIma02071MU3Uf9KHrmV1/+y8DAAAAAAAAAAAAAAAAAAAAAMB/9A6txIuJACgAAA== ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 676 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="file"; filename="binaryfile.tar.gz" +Content-Type: application/x-gzip +Content-Transfer-Encoding: base64 + +H4sIAGiNIU8AA+3R0W6CMBQGYK59iobLZantRDG73osUOGqnFNJWM2N897UghG1ZdmWWLf93U/jP4bRAq8q92hJ/dY1J7kQEqyyLq8yXYrp2ltkqkTKXYiEykYc++ZTLVcLEvQ40dXReWcYSV1pdnL/v+6n+R11mjKVG1ZQ+s3TT2FpXqjhQ+hjzE1mnGxNLkgu+7tOKWjIVmVKTC6XL9ZaeXj4VQhwKWzL+cI4zwgQuuhkh3mhTad/Hkssh3im3027X54JnQ360R/M19OT8kC7SEN7Ooi2VvrEfznHQRWzl83gxttZKmzGehzPRW/+W8X+3fvL8sFet9sS6m3EIma02071MU3Uf9KHrmV1/+y8DAAAAAAAAAAAAAAAAAAAAAMB/9A6txIuJACgAAA== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/test/fixture/http/encoding/blank.gif.http b/test-node/fixture/http/encoding/blank.gif.http similarity index 97% rename from test/fixture/http/encoding/blank.gif.http rename to test-node/fixture/http/encoding/blank.gif.http index 7426f5b6..cf54956d 100644 --- a/test/fixture/http/encoding/blank.gif.http +++ b/test-node/fixture/http/encoding/blank.gif.http @@ -1,12 +1,12 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Length: 323 - ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -Content-Disposition: form-data; name="file"; filename="blank.gif" -Content-Type: image/gif -Content-Transfer-Encoding: base64 - -R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw== ---\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Length: 323 + +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +Content-Disposition: form-data; name="file"; filename="blank.gif" +Content-Type: image/gif +Content-Transfer-Encoding: base64 + +R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw== +--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-- diff --git a/test/fixture/http/encoding/menu_separator.png.http b/test-node/fixture/http/encoding/menu_separator.png.http similarity index 100% rename from test/fixture/http/encoding/menu_separator.png.http rename to test-node/fixture/http/encoding/menu_separator.png.http diff --git a/test/fixture/http/encoding/plain.txt.http b/test-node/fixture/http/encoding/plain.txt.http similarity index 96% rename from test/fixture/http/encoding/plain.txt.http rename to test-node/fixture/http/encoding/plain.txt.http index 5e85ad6b..230b2054 100644 --- a/test/fixture/http/encoding/plain.txt.http +++ b/test-node/fixture/http/encoding/plain.txt.http @@ -1,13 +1,13 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 221 - -------TLV0SrKD4z1TRxRhAPUvZ -Content-Disposition: form-data; name="file"; filename="plain.txt" -Content-Type: text/plain -Content-Transfer-Encoding: 7bit - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 221 + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="file"; filename="plain.txt" +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + I am a plain text file - -------TLV0SrKD4z1TRxRhAPUvZ-- + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/test/fixture/http/misc/empty-multipart.http b/test-node/fixture/http/misc/empty-multipart.http similarity index 96% rename from test/fixture/http/misc/empty-multipart.http rename to test-node/fixture/http/misc/empty-multipart.http index 81c61255..25575edf 100644 --- a/test/fixture/http/misc/empty-multipart.http +++ b/test-node/fixture/http/misc/empty-multipart.http @@ -1,5 +1,5 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 0 - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 0 + diff --git a/test/fixture/http/misc/empty-multipart2.http b/test-node/fixture/http/misc/empty-multipart2.http similarity index 96% rename from test/fixture/http/misc/empty-multipart2.http rename to test-node/fixture/http/misc/empty-multipart2.http index eda65284..b2717ac3 100644 --- a/test/fixture/http/misc/empty-multipart2.http +++ b/test-node/fixture/http/misc/empty-multipart2.http @@ -1,6 +1,6 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 31 - -------TLV0SrKD4z1TRxRhAPUvZ-- +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 31 + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/test/fixture/http/misc/empty-urlencoded.http b/test-node/fixture/http/misc/empty-urlencoded.http similarity index 95% rename from test/fixture/http/misc/empty-urlencoded.http rename to test-node/fixture/http/misc/empty-urlencoded.http index bb197d3e..421c20cb 100644 --- a/test/fixture/http/misc/empty-urlencoded.http +++ b/test-node/fixture/http/misc/empty-urlencoded.http @@ -1,5 +1,5 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Length: 0 -Content-Type: application/x-www-form-urlencoded - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Length: 0 +Content-Type: application/x-www-form-urlencoded + diff --git a/test/fixture/http/misc/empty.http b/test-node/fixture/http/misc/empty.http similarity index 93% rename from test/fixture/http/misc/empty.http rename to test-node/fixture/http/misc/empty.http index 4c4cee56..9102ada8 100644 --- a/test/fixture/http/misc/empty.http +++ b/test-node/fixture/http/misc/empty.http @@ -1,4 +1,4 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Length: 0 - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Length: 0 + diff --git a/test/fixture/http/misc/minimal.http b/test-node/fixture/http/misc/minimal.http similarity index 93% rename from test/fixture/http/misc/minimal.http rename to test-node/fixture/http/misc/minimal.http index 594cdd31..beb12f7c 100644 --- a/test/fixture/http/misc/minimal.http +++ b/test-node/fixture/http/misc/minimal.http @@ -1,3 +1,3 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 - +POST /upload HTTP/1.1 +Host: localhost:8080 + diff --git a/test/fixture/http/no-filename/filename-name.http b/test-node/fixture/http/no-filename/filename-name.http similarity index 96% rename from test/fixture/http/no-filename/filename-name.http rename to test-node/fixture/http/no-filename/filename-name.http index 7b3dac1b..e449156b 100644 --- a/test/fixture/http/no-filename/filename-name.http +++ b/test-node/fixture/http/no-filename/filename-name.http @@ -1,13 +1,13 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Length: 1000 - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Disposition: form-data; filename="plain.txt"; name="upload" -Content-Type: text/plain - -I am a plain text file - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Length: 1000 + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; filename="plain.txt"; name="upload" +Content-Type: text/plain + +I am a plain text file + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- + diff --git a/test/fixture/http/no-filename/generic.http b/test-node/fixture/http/no-filename/generic.http similarity index 96% rename from test/fixture/http/no-filename/generic.http rename to test-node/fixture/http/no-filename/generic.http index e0dee27c..c051d852 100644 --- a/test/fixture/http/no-filename/generic.http +++ b/test-node/fixture/http/no-filename/generic.http @@ -1,13 +1,13 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Length: 1000 - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Disposition: form-data; name="upload"; filename="" -Content-Type: text/plain - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Length: 1000 + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="upload"; filename="" +Content-Type: text/plain + I am a plain text file - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- diff --git a/test/fixture/http/preamble/crlf.http b/test-node/fixture/http/preamble/crlf.http similarity index 96% rename from test/fixture/http/preamble/crlf.http rename to test-node/fixture/http/preamble/crlf.http index 1d5f7095..1357950a 100644 --- a/test/fixture/http/preamble/crlf.http +++ b/test-node/fixture/http/preamble/crlf.http @@ -1,13 +1,13 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 184 - - -------TLV0SrKD4z1TRxRhAPUvZ -Content-Disposition: form-data; name="upload"; filename="plain.txt" -Content-Type: text/plain - +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 184 + + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + I am a plain text file - -------TLV0SrKD4z1TRxRhAPUvZ-- + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/test/fixture/http/preamble/preamble.http b/test-node/fixture/http/preamble/preamble.http similarity index 96% rename from test/fixture/http/preamble/preamble.http rename to test-node/fixture/http/preamble/preamble.http index cdd86ace..ab490a36 100644 --- a/test/fixture/http/preamble/preamble.http +++ b/test-node/fixture/http/preamble/preamble.http @@ -1,13 +1,13 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 226 - -This is a preamble which should be ignored -------TLV0SrKD4z1TRxRhAPUvZ -Content-Disposition: form-data; name="upload"; filename="plain.txt" -Content-Type: text/plain - -I am a plain text file - -------TLV0SrKD4z1TRxRhAPUvZ-- +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 226 + +This is a preamble which should be ignored +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a plain text file + +------TLV0SrKD4z1TRxRhAPUvZ-- diff --git a/test/fixture/http/special-chars-in-filename/info.md b/test-node/fixture/http/special-chars-in-filename/info.md similarity index 100% rename from test/fixture/http/special-chars-in-filename/info.md rename to test-node/fixture/http/special-chars-in-filename/info.md diff --git a/test/fixture/http/special-chars-in-filename/line-separator.http b/test-node/fixture/http/special-chars-in-filename/line-separator.http similarity index 100% rename from test/fixture/http/special-chars-in-filename/line-separator.http rename to test-node/fixture/http/special-chars-in-filename/line-separator.http diff --git a/test/fixture/http/special-chars-in-filename/osx-chrome-13.http b/test-node/fixture/http/special-chars-in-filename/osx-chrome-13.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/osx-chrome-13.http rename to test-node/fixture/http/special-chars-in-filename/osx-chrome-13.http index 4ef39172..6dec0d38 100644 --- a/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +++ b/test-node/fixture/http/special-chars-in-filename/osx-chrome-13.http @@ -1,26 +1,26 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Connection: keep-alive -Referer: http://localhost:8080/ -Content-Length: 383 -Cache-Control: max-age=0 -Origin: http://localhost:8080 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1 -Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: en-US,en;q=0.8 -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 -Cookie: jqCookieJar_tablesorter=%7B%22showListTable%22%3A%5B%5B5%2C1%5D%2C%5B1%2C0%5D%5D%7D - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Disposition: form-data; name="title" - -Weird filename -------WebKitFormBoundarytyE4wkKlZ5CQJVTG -Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: text/plain - +POST /upload HTTP/1.1 +Host: localhost:8080 +Connection: keep-alive +Referer: http://localhost:8080/ +Content-Length: 383 +Cache-Control: max-age=0 +Origin: http://localhost:8080 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en-US,en;q=0.8 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 +Cookie: jqCookieJar_tablesorter=%7B%22showListTable%22%3A%5B%5B5%2C1%5D%2C%5B1%2C0%5D%5D%7D + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundarytyE4wkKlZ5CQJVTG +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + I am a text file with a funky name! - -------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- + +------WebKitFormBoundarytyE4wkKlZ5CQJVTG-- diff --git a/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http b/test-node/fixture/http/special-chars-in-filename/osx-firefox-3.6.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http rename to test-node/fixture/http/special-chars-in-filename/osx-firefox-3.6.http index bf49f85f..76ff2b34 100644 --- a/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +++ b/test-node/fixture/http/special-chars-in-filename/osx-firefox-3.6.http @@ -1,24 +1,24 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22 -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -Accept-Language: en-us,en;q=0.5 -Accept-Encoding: gzip,deflate -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 -Keep-Alive: 115 -Connection: keep-alive -Referer: http://localhost:8080/ -Content-Type: multipart/form-data; boundary=---------------------------9849436581144108930470211272 -Content-Length: 438 - ------------------------------9849436581144108930470211272 -Content-Disposition: form-data; name="title" - -Weird filename ------------------------------9849436581144108930470211272 -Content-Disposition: form-data; name="upload"; filename=": \ ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: text/plain - +POST /upload HTTP/1.1 +Host: localhost:8080 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22 +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Language: en-us,en;q=0.5 +Accept-Encoding: gzip,deflate +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 +Keep-Alive: 115 +Connection: keep-alive +Referer: http://localhost:8080/ +Content-Type: multipart/form-data; boundary=---------------------------9849436581144108930470211272 +Content-Length: 438 + +-----------------------------9849436581144108930470211272 +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------9849436581144108930470211272 +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + I am a text file with a funky name! - ------------------------------9849436581144108930470211272-- + +-----------------------------9849436581144108930470211272-- diff --git a/test/fixture/http/special-chars-in-filename/osx-safari-5.http b/test-node/fixture/http/special-chars-in-filename/osx-safari-5.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/osx-safari-5.http rename to test-node/fixture/http/special-chars-in-filename/osx-safari-5.http index ff158a43..b3652d90 100644 --- a/test/fixture/http/special-chars-in-filename/osx-safari-5.http +++ b/test-node/fixture/http/special-chars-in-filename/osx-safari-5.http @@ -1,23 +1,23 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Origin: http://localhost:8080 -Content-Length: 383 -User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 -Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQJZ1gvhvdgfisJPJ -Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 -Referer: http://localhost:8080/ -Accept-Language: en-us -Accept-Encoding: gzip, deflate -Connection: keep-alive - -------WebKitFormBoundaryQJZ1gvhvdgfisJPJ -Content-Disposition: form-data; name="title" - -Weird filename -------WebKitFormBoundaryQJZ1gvhvdgfisJPJ -Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: text/plain - +POST /upload HTTP/1.1 +Host: localhost:8080 +Origin: http://localhost:8080 +Content-Length: 383 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Referer: http://localhost:8080/ +Accept-Language: en-us +Accept-Encoding: gzip, deflate +Connection: keep-alive + +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ +Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + I am a text file with a funky name! - -------WebKitFormBoundaryQJZ1gvhvdgfisJPJ-- + +------WebKitFormBoundaryQJZ1gvhvdgfisJPJ-- diff --git a/test/fixture/http/special-chars-in-filename/xp-chrome-12.http b/test-node/fixture/http/special-chars-in-filename/xp-chrome-12.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/xp-chrome-12.http rename to test-node/fixture/http/special-chars-in-filename/xp-chrome-12.http index f0fc533a..ef8d1d60 100644 --- a/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +++ b/test-node/fixture/http/special-chars-in-filename/xp-chrome-12.http @@ -1,24 +1,24 @@ -POST /upload HTTP/1.1 -Host: 192.168.56.1:8080 -Connection: keep-alive -Referer: http://192.168.56.1:8080/ -Content-Length: 344 -Cache-Control: max-age=0 -Origin: http://192.168.56.1:8080 -User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30 -Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryEvqBNplR3ByrwQPa -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 - -------WebKitFormBoundaryEvqBNplR3ByrwQPa -Content-Disposition: form-data; name="title" - -Weird filename -------WebKitFormBoundaryEvqBNplR3ByrwQPa -Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: text/plain - - -------WebKitFormBoundaryEvqBNplR3ByrwQPa-- +POST /upload HTTP/1.1 +Host: 192.168.56.1:8080 +Connection: keep-alive +Referer: http://192.168.56.1:8080/ +Content-Length: 344 +Cache-Control: max-age=0 +Origin: http://192.168.56.1:8080 +User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30 +Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryEvqBNplR3ByrwQPa +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 + +------WebKitFormBoundaryEvqBNplR3ByrwQPa +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundaryEvqBNplR3ByrwQPa +Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + + +------WebKitFormBoundaryEvqBNplR3ByrwQPa-- diff --git a/test/fixture/http/special-chars-in-filename/xp-ie-7.http b/test-node/fixture/http/special-chars-in-filename/xp-ie-7.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/xp-ie-7.http rename to test-node/fixture/http/special-chars-in-filename/xp-ie-7.http index 2e2c61c7..4befdc71 100644 --- a/test/fixture/http/special-chars-in-filename/xp-ie-7.http +++ b/test-node/fixture/http/special-chars-in-filename/xp-ie-7.http @@ -1,22 +1,22 @@ -POST /upload HTTP/1.1 -Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* -Referer: http://192.168.56.1:8080/ -Accept-Language: de -User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) -Content-Type: multipart/form-data; boundary=---------------------------7db1fe232017c -Accept-Encoding: gzip, deflate -Host: 192.168.56.1:8080 -Content-Length: 368 -Connection: Keep-Alive -Cache-Control: no-cache - ------------------------------7db1fe232017c -Content-Disposition: form-data; name="title" - -Weird filename ------------------------------7db1fe232017c -Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: application/octet-stream - - ------------------------------7db1fe232017c-- +POST /upload HTTP/1.1 +Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* +Referer: http://192.168.56.1:8080/ +Accept-Language: de +User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) +Content-Type: multipart/form-data; boundary=---------------------------7db1fe232017c +Accept-Encoding: gzip, deflate +Host: 192.168.56.1:8080 +Content-Length: 368 +Connection: Keep-Alive +Cache-Control: no-cache + +-----------------------------7db1fe232017c +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------7db1fe232017c +Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: application/octet-stream + + +-----------------------------7db1fe232017c-- diff --git a/test/fixture/http/special-chars-in-filename/xp-ie-8.http b/test-node/fixture/http/special-chars-in-filename/xp-ie-8.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/xp-ie-8.http rename to test-node/fixture/http/special-chars-in-filename/xp-ie-8.http index e2b94fae..9c1c5330 100644 --- a/test/fixture/http/special-chars-in-filename/xp-ie-8.http +++ b/test-node/fixture/http/special-chars-in-filename/xp-ie-8.http @@ -1,22 +1,22 @@ -POST /upload HTTP/1.1 -Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* -Referer: http://192.168.56.1:8080/ -Accept-Language: de -User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) -Content-Type: multipart/form-data; boundary=---------------------------7db3a8372017c -Accept-Encoding: gzip, deflate -Host: 192.168.56.1:8080 -Content-Length: 368 -Connection: Keep-Alive -Cache-Control: no-cache - ------------------------------7db3a8372017c -Content-Disposition: form-data; name="title" - -Weird filename ------------------------------7db3a8372017c -Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: application/octet-stream - - ------------------------------7db3a8372017c-- +POST /upload HTTP/1.1 +Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */* +Referer: http://192.168.56.1:8080/ +Accept-Language: de +User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) +Content-Type: multipart/form-data; boundary=---------------------------7db3a8372017c +Accept-Encoding: gzip, deflate +Host: 192.168.56.1:8080 +Content-Length: 368 +Connection: Keep-Alive +Cache-Control: no-cache + +-----------------------------7db3a8372017c +Content-Disposition: form-data; name="title" + +Weird filename +-----------------------------7db3a8372017c +Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: application/octet-stream + + +-----------------------------7db3a8372017c-- diff --git a/test/fixture/http/special-chars-in-filename/xp-safari-5.http b/test-node/fixture/http/special-chars-in-filename/xp-safari-5.http similarity index 97% rename from test/fixture/http/special-chars-in-filename/xp-safari-5.http rename to test-node/fixture/http/special-chars-in-filename/xp-safari-5.http index 6379ac01..2b7bacb5 100644 --- a/test/fixture/http/special-chars-in-filename/xp-safari-5.http +++ b/test-node/fixture/http/special-chars-in-filename/xp-safari-5.http @@ -1,22 +1,22 @@ -POST /upload HTTP/1.1 -Host: 192.168.56.1:8080 -Referer: http://192.168.56.1:8080/ -Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 -Accept-Language: en-US -Origin: http://192.168.56.1:8080 -User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4 -Accept-Encoding: gzip, deflate -Content-Type: multipart/form-data; boundary=----WebKitFormBoundarykmaWSUbu697WN9TM -Content-Length: 344 -Connection: keep-alive - -------WebKitFormBoundarykmaWSUbu697WN9TM -Content-Disposition: form-data; name="title" - -Weird filename -------WebKitFormBoundarykmaWSUbu697WN9TM -Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" -Content-Type: text/plain - - -------WebKitFormBoundarykmaWSUbu697WN9TM-- +POST /upload HTTP/1.1 +Host: 192.168.56.1:8080 +Referer: http://192.168.56.1:8080/ +Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Accept-Language: en-US +Origin: http://192.168.56.1:8080 +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4 +Accept-Encoding: gzip, deflate +Content-Type: multipart/form-data; boundary=----WebKitFormBoundarykmaWSUbu697WN9TM +Content-Length: 344 +Connection: keep-alive + +------WebKitFormBoundarykmaWSUbu697WN9TM +Content-Disposition: form-data; name="title" + +Weird filename +------WebKitFormBoundarykmaWSUbu697WN9TM +Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt" +Content-Type: text/plain + + +------WebKitFormBoundarykmaWSUbu697WN9TM-- diff --git a/test/fixture/http/workarounds/missing-hyphens1.http b/test-node/fixture/http/workarounds/missing-hyphens1.txt.http similarity index 96% rename from test/fixture/http/workarounds/missing-hyphens1.http rename to test-node/fixture/http/workarounds/missing-hyphens1.txt.http index 996a48bc..d4104d40 100644 --- a/test/fixture/http/workarounds/missing-hyphens1.http +++ b/test-node/fixture/http/workarounds/missing-hyphens1.txt.http @@ -1,12 +1,12 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ -Content-Length: 189 - -------TLV0SrKD4z1TRxRhAPUvZ -Content-Disposition: form-data; name="upload"; filename="plain.txt" -Content-Type: text/plain - -I am a simple plain text file - -------TLV0SrKD4z1TRxRhAPUvZ +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLV0SrKD4z1TRxRhAPUvZ +Content-Length: 189 + +------TLV0SrKD4z1TRxRhAPUvZ +Content-Disposition: form-data; name="upload"; filename="plain.txt" +Content-Type: text/plain + +I am a simple plain text file + +------TLV0SrKD4z1TRxRhAPUvZ diff --git a/test/fixture/http/workarounds/missing-hyphens2.http b/test-node/fixture/http/workarounds/missing-hyphens2.txt.http similarity index 96% rename from test/fixture/http/workarounds/missing-hyphens2.http rename to test-node/fixture/http/workarounds/missing-hyphens2.txt.http index 524875d3..0eaac33d 100644 --- a/test/fixture/http/workarounds/missing-hyphens2.http +++ b/test-node/fixture/http/workarounds/missing-hyphens2.txt.http @@ -1,12 +1,12 @@ -POST /upload HTTP/1.1 -Host: localhost:8080 -Content-Type: multipart/form-data; boundary=----TLVx0SrKD4z1TRxRhAPUvZx -Content-Length: 209 - -------TLVx0SrKD4z1TRxRhAPUvZx -Content-Disposition: form-data; name="upload"; filename="second-plaintext.txt" -Content-Type: text/plain - -Some another plain text file, yeah! - -------TLVx0SrKD4z1TRxRhAPUvZx +POST /upload HTTP/1.1 +Host: localhost:8080 +Content-Type: multipart/form-data; boundary=----TLVx0SrKD4z1TRxRhAPUvZx +Content-Length: 209 + +------TLVx0SrKD4z1TRxRhAPUvZx +Content-Disposition: form-data; name="upload"; filename="second-plaintext.txt" +Content-Type: text/plain + +Some another plain text file, yeah! + +------TLVx0SrKD4z1TRxRhAPUvZx diff --git a/test/fixture/js/encoding.js b/test-node/fixture/js/encoding.js similarity index 100% rename from test/fixture/js/encoding.js rename to test-node/fixture/js/encoding.js diff --git a/test/fixture/js/misc.js b/test-node/fixture/js/misc.js similarity index 100% rename from test/fixture/js/misc.js rename to test-node/fixture/js/misc.js diff --git a/test/fixture/js/no-filename.js b/test-node/fixture/js/no-filename.js similarity index 100% rename from test/fixture/js/no-filename.js rename to test-node/fixture/js/no-filename.js diff --git a/test/fixture/js/preamble.js b/test-node/fixture/js/preamble.js similarity index 100% rename from test/fixture/js/preamble.js rename to test-node/fixture/js/preamble.js diff --git a/test/fixture/js/special-chars-in-filename.js b/test-node/fixture/js/special-chars-in-filename.js similarity index 100% rename from test/fixture/js/special-chars-in-filename.js rename to test-node/fixture/js/special-chars-in-filename.js diff --git a/test/fixture/js/workarounds.js b/test-node/fixture/js/workarounds.js similarity index 71% rename from test/fixture/js/workarounds.js rename to test-node/fixture/js/workarounds.js index c3ab14b7..cbcc656c 100644 --- a/test/fixture/js/workarounds.js +++ b/test-node/fixture/js/workarounds.js @@ -3,7 +3,7 @@ const missing_hyphens1_http = [ type: 'file', name: 'upload', originalFilename: 'plain.txt', - fixture: 'missing-hyphens1', + fixture: 'missing-hyphens1.txt', sha1: '8c26b82ec9107e99b3486844644e92558efe0c73', }, ]; @@ -13,9 +13,12 @@ const missing_hyphens2_http = [ type: 'file', name: 'upload', originalFilename: 'second-plaintext.txt', - fixture: 'missing-hyphens2', + fixture: 'missing-hyphens2.txt', sha1: '798e39a4a1034232ed26e0aadd67f5d1ff10b966', }, ]; -export { missing_hyphens1_http, missing_hyphens2_http }; +export { + missing_hyphens1_http, + // missing_hyphens2_http, +}; diff --git a/test/fixture/multi_video.upload b/test-node/fixture/multi_video.upload similarity index 100% rename from test/fixture/multi_video.upload rename to test-node/fixture/multi_video.upload diff --git a/test/fixture/multipart.js b/test-node/fixture/multipart.js similarity index 100% rename from test/fixture/multipart.js rename to test-node/fixture/multipart.js diff --git a/test-node/integration/fixtures.test.js b/test-node/integration/fixtures.test.js new file mode 100644 index 00000000..03cf90fa --- /dev/null +++ b/test-node/integration/fixtures.test.js @@ -0,0 +1,175 @@ +/* eslint-disable global-require */ +/* eslint-disable import/no-dynamic-require */ + +import { strictEqual, deepEqual } from 'node:assert'; +import test from 'node:test'; +import { createReadStream, constants, accessSync } from 'node:fs'; +import { createConnection } from 'node:net'; +import { join } from 'node:path'; +import { createServer } from 'node:http'; +import { pipeline } from 'node:stream'; +import formidable from '../../src/index.js'; + + +const PORT = 13534; +const CWDTest = join(process.cwd(), "test-node"); +const FIXTURES_HTTP = join(CWDTest, 'fixture', 'http'); +const UPLOAD_DIR = join(CWDTest, 'tmp'); +import * as encoding from "../fixture/js/encoding.js"; +import * as misc from "../fixture/js/misc.js"; +import * as noFilename from "../fixture/js/no-filename.js"; +import * as preamble from "../fixture/js/preamble.js"; +import * as workarounds from "../fixture/js/workarounds.js"; +import * as specialCharsInFilename from "../fixture/js/special-chars-in-filename.js"; + +const fixtures = { + encoding, + // misc, + // [`no-filename`]: noFilename, + // preamble, + // [`special-chars-in-filename`]: specialCharsInFilename, + // workarounds, // todo uncomment this and make it work +}; + + +test('fixtures', (testContext, done) => { + const server = createServer(); + server.listen(PORT, findFixtures); + + function properExitTest(...x) { + server.close(); + done(...x) + } + function strictEqualExit(...x) { + try { + strictEqual(...x) + } catch (assertionError) { + properExitTest(assertionError); + throw assertionError; + } + } + + + function findFixtures() { + const remainingFixtures = Object.entries(fixtures).map(([fixtureGroup, fixture]) => { + return Object.entries(fixture).map(([k, v]) => { + return v.map(details => { + + return { + fixture: v, + name: `${fixtureGroup}/${details.fixture}.http`, + http: join(FIXTURES_HTTP, fixtureGroup, `${details.fixture}.http`), + }; + }); + }); + }).flat(Infinity); + testNext(remainingFixtures); + } + + function testNext(remainingFixtures) { + const fixtureWithName = remainingFixtures.shift(); + if (!fixtureWithName) { + properExitTest(); + return; + } + const fixtureName = fixtureWithName.name; + const fixture = fixtureWithName.fixture; + + uploadFixture(fixtureWithName, (err, parts) => { + if (err) { + err.fixtureName = fixtureName; + properExitTest(new Error(err)); + return; + } + + fixture.forEach((expectedPart, i) => { + const parsedPart = parts[i]; + strictEqualExit(parsedPart.type, expectedPart.type); + strictEqualExit(parsedPart.name, expectedPart.name); + + if (parsedPart.type === 'file') { + const file = parsedPart.value; + strictEqualExit(file.originalFilename, expectedPart.originalFilename, + `${JSON.stringify([expectedPart, file])}`); + + if (expectedPart.sha1) { + strictEqualExit( + file.hash, + expectedPart.sha1, + `SHA1 error ${file.originalFilename} on ${file.filepath} ${JSON.stringify([expectedPart, file])}`, + ); + } + } + }); + + testNext(remainingFixtures); + }); + } + + function uploadFixture(fixtureWithName, verifyFixture) { + + const fixturePath = fixtureWithName.http; + let verifyFixtureOnce = verifyFixture; + + try { + accessSync(fixturePath, constants.W_OK | constants.R_OK); + } catch (err) { + properExitTest(new Error(`can't open ${fixturePath}`)); + } + const socket = createConnection(PORT); + const file = createReadStream(fixturePath); + + // make sure verifyFixture is only called once + function callback(...args) { + const realCallback = verifyFixtureOnce; + verifyFixtureOnce = function callbackFn() { }; + if (socket.writable) { + socket.destroy(); + } + realCallback(...args); + } + + server.once('request', (req, res) => { + const form = formidable({ + uploadDir: UPLOAD_DIR, + hashAlgorithm: 'sha1', + keepExtensions: true, + }); + + const parts = []; + form + .once('error', (error) => { + const a = form; + const b = a; + const c = a._parser.explain(); + console.log(c); + callback(error); + }) + .on('fileBegin', (name, value) => { + parts.push({ type: 'file', name, value }); + }) + .on('field', (name, value) => { + parts.push({ type: 'field', name, value }); + }) + .once('end', () => { + res.end(); + callback(null, parts); + }); + form.parse(req); + }); + + + // file.pipe(socket, {end: true}); + pipeline( + file, + socket, + (err) => { + if (err) { + console.error('error'); + } else { + console.log("success") + } + }, + ); + } +}); diff --git a/test/integration/fixtures.test.js b/test/integration/fixtures.test.js deleted file mode 100644 index a37840c0..00000000 --- a/test/integration/fixtures.test.js +++ /dev/null @@ -1,131 +0,0 @@ -/* eslint-disable global-require */ -/* eslint-disable import/no-dynamic-require */ - -import { createReadStream } from 'node:fs'; -import { createConnection } from 'node:net'; -import { join } from 'node:path'; -import { createServer } from 'node:http'; -import { strictEqual } from 'node:assert'; - -import formidable from '../../src/index.js'; - -const PORT = 13534; -const CWD = process.cwd(); -const FIXTURES_HTTP = join(CWD, 'test', 'fixture', 'http'); -const UPLOAD_DIR = join(CWD, 'test', 'tmp'); -import * as encoding from "../fixture/js/encoding.js"; -import * as misc from "../fixture/js/misc.js"; -import * as noFilename from "../fixture/js/no-filename.js"; -import * as preamble from "../fixture/js/preamble.js"; -import * as workarounds from "../fixture/js/workarounds.js"; -import * as specialCharsInFilename from "../fixture/js/special-chars-in-filename.js"; - -const fixtures= { - encoding, - misc, - [`no-filename`]: noFilename, - preamble, - [`special-chars-in-filename`]: specialCharsInFilename, - // workarounds, // todo uncomment this and make it work -}; - -test('fixtures', (done) => { - const server = createServer(); - server.listen(PORT, findFixtures); - - function findFixtures() { - const results = Object.entries(fixtures).map(([fixtureGroup, fixture]) => { - return Object.entries(fixture).map(([k, v]) => { - return v.map(details => { - return { - fixture: v, - name: `${fixtureGroup}/${details.fixture}.http` - }; - }); - }); - }).flat(Infinity); - testNext(results); - } - - function testNext(results) { - const fixtureWithName = results.shift(); - if (!fixtureWithName) { - server.close(); - done(); - return; - } - const fixtureName = fixtureWithName.name; - const fixture = fixtureWithName.fixture; - - uploadFixture(fixtureName, (err, parts) => { - if (err) { - err.fixtureName = fixtureName; - throw err; - } - - fixture.forEach((expectedPart, i) => { - const parsedPart = parts[i]; - strictEqual(parsedPart.type, expectedPart.type); - strictEqual(parsedPart.name, expectedPart.name); - - if (parsedPart.type === 'file') { - const file = parsedPart.value; - strictEqual(file.originalFilename, expectedPart.originalFilename, - `${JSON.stringify([expectedPart, file])}`); - - if (expectedPart.sha1) { - strictEqual( - file.hash, - expectedPart.sha1, - `SHA1 error ${file.originalFilename} on ${file.filepath} ${JSON.stringify([expectedPart, file])}`, - ); - } - } - }); - - testNext(results); - }); - } - - function uploadFixture(fixtureName, cb) { - server.once('request', (req, res) => { - const form = formidable({ - uploadDir: UPLOAD_DIR, - hashAlgorithm: 'sha1', - }); - form.parse(req); - - function callback(...args) { - const realCallback = cb; - // eslint-disable-next-line no-param-reassign - cb = function callbackFn() {}; - - realCallback(...args); - } - - const parts = []; - form - .on('error', callback) - .on('fileBegin', (name, value) => { - parts.push({ type: 'file', name, value }); - }) - .on('field', (name, value) => { - parts.push({ type: 'field', name, value }); - }) - .on('end', () => { - res.end(); - callback(null, parts); - }); - }); - - const socket = createConnection(PORT); - const fixturePath = join(FIXTURES_HTTP, fixtureName); - const file = createReadStream(fixturePath); - - file.pipe(socket, { end: false }); - - socket.on('data', () => { - socket.end(); - }); - } -});