Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.http -text
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]

Parse http requests with content-type `multipart/form-data`, also known as file uploads.
Parse http requests with content-type `multipart/form-data`, also known as file uploads, or `multipart/mixed`.

See also [busboy](https://github.com/mscdex/busboy) - a
[faster](https://github.com/mscdex/dicer/wiki/Benchmarks) alternative
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var COLON = 58;
var A = 97;
var Z = 122;

var CONTENT_TYPE_RE = /^multipart\/(?:form-data|related)(?:;|$)/i;
var CONTENT_TYPE_RE = /^multipart\/(?:form-data|related|mixed)(?:;|$)/i;
var CONTENT_TYPE_PARAM_RE = /;\s*([^=]+)=(?:"([^"]+)"|([^;]+))/gi;
var FILE_EXT_RE = /(\.[_\-a-zA-Z0-9]{0,16}).*/;
var LAST_BOUNDARY_SUFFIX_LEN = 4; // --\r\n
Expand Down
13 changes: 13 additions & 0 deletions test/fixture/http/content-type/multipart-mixed.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
POST /upload HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; custom=stuff; boundary=----TLV0SrKD4z1TRxRhAPUvZ
Content-Length: 213

------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--
11 changes: 11 additions & 0 deletions test/fixture/js/content-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ module.exports['custom-equal-sign.http'] = [
size: 24,
}
];

module.exports['multipart-mixed.http'] = [
{
type: 'file',
name: 'file',
filename: 'plain.txt',
fixture: 'plain.txt',
sha1: 'b31d07bac24ac32734de88b3687dddb10e976872',
size: 23,
}
];