Permalink
Browse files

Remove multipart library

Too messy, unmaintainable. Pull it out of the history if you need it.
  • Loading branch information...
1 parent 53530e9 commit 94644d743c0aa04fb2bc9e1267205b02c6ee7f82 @ry ry committed Apr 2, 2010
Showing with 0 additions and 1,469 deletions.
  1. +0 −170 doc/api.markdown
  2. +0 −437 lib/multipart.js
  3. +0 −1 src/node.cc
  4. +0 −721 test/fixtures/multipart.js
  5. +0 −140 test/pummel/test-multipart.js
View
@@ -1483,176 +1483,6 @@ Resumes a paused response.
A reference to the `http.Client` that this response belongs to.
-## Multipart Parsing
-
-A library to parse `multipart` internet messages is included with
-Node. To use it, `require("multipart")`.
-
-### multipart.parse(message)
-
-Returns a multipart.Stream wrapper around a streaming message.
-The message must contain a `headers` member, and may be either an
-HTTP request object or a JSGI-style request object with either a
-forEachable or String body.
-
-See the Stream class below.
-
-### multipart.cat(message, callback)
-
-On success, `callback` is called with `(null, stream)` where `stream` is a
-`multipart.Stream` object representing the completed message. The body of
-each part is saved on the `body` member.
-
-On error, `callback` is called with `(err)` where `err` is an instanceof
-the `Error` object. This indicates that the message was malformed in some
-way.
-
-*Note*: This function saves the *entire* message into memory. As such, it
-is ill-suited to parsing actual incoming messages from an HTTP request!
-If a user uploads a very large file, then it may cause serious problems.
-No checking is done to ensure that the file does not overload the memory.
-Only use `multipart.cat` with known and trusted input!
-
-
-### multipart.Stream
-
-The multipart.Stream class is a streaming parser wrapped around a message.
-The Stream also contains the properties described for the `part` objects below, and is a reference to the top-level message.
-
-This is an EventEmitter with the following events:
-
-- **`"partBegin"`** - `callback(part)`:
-Emitted when a new part is found in the stream. `part` is a `part object`, described below.
-
-- **`"partEnd"`** - `callback(part)`:
- Emitted when a part is done.
-
-- **`"body"`** - `callback(chunk)`:
- Emitted when a chunk of the body is read.
-
-- **`"complete"`** - `callback()`:
- Emitted when the end of the stream is reached.
-
-- **`"error"`** - `callback(error)`:
- Emitted when a parse error is encountered. This indicates that the message is malformed.
-
-
-### stream.part
-
-The current part being processed. This is important, for instance, when
-responding to the `body` event.
-
-### stream.isMultiPart
-
-True if the stream is a multipart message. Generally this will be true, but
-non-multipart messages will behave the same as a multipart message with a
-single part, and `isMultiPart` will be set to `false`.
-
-### stream.parts
-
-An array of the parts contained within the message. Each is a `part` object.
-
-### stream.pause
-
-If the underlying message supports pause and resume, then this will pause the
-stream.
-
-### stream.resume
-
-If the underlying message supports pause and resume, then this will resume the
-paused stream.
-
-### multipart.Part
-
-As it parses the message, the Stream object will create `Part` objects.
-
-### part.parent
-
-The message that contains this part.
-
-### part.headers
-
-The headers object for this message.
-
-### part.filename
-
-The filename, if specified in the `content-disposition` or `content-type`
-header. For uploads, downloads, and attachments, this is the intended filename
-for the attached file.
-
-### part.name
-
-The name, if specified in the `content-disposition` or `content-type` header.
-For `multipart/form-data` messages, this is the name of the field that was
-posted, and the body specifies the value.
-
-### part.isMultiPart
-
-True if this part is a multipart message.
-
-### part.parts
-
-Array of children contained within a multipart message, or falsey.
-
-### part.boundary
-
-For multipart messages, this is the boundary that separates subparts.
-
-### part.type
-
-For multipart messages, this is the multipart type specified in the
-`content-type` header. For example, a message with `content-type: multipart/form-data` will have a `type` property of `form-data`.
-
-### Example
-
-Here is an example for parsing a `multipart/form-data` request:
-
-
- var multipart = require("multipart"),
- sys = require("sys"),
- http = require("http");
- http.createServer(function (req, res) {
- var mp = multipart.parse(req),
- fields = {},
- name, filename;
- mp.addListener("error", function (er) {
- res.writeHead(400, {"content-type":"text/plain"});
- res.write("You sent a bad message!\n"+er.message);
- res.close();
- });
- mp.addListener("partBegin", function (part) {
- name = part.name;
- filename = part.filename;
- if (name) fields[name] = "";
- });
- mp.addListener("body", function (chunk) {
- if (name) {
- // just a demo. in reality, you'd probably
- // want to sniff for base64 encoding, decode,
- // and write the bytes to a file or something.
- if (fields[name].length > 1024) return;
- fields[name] += chunk;
- }
- });
- mp.addListener("complete", function () {
- var response = "You posted: \n" + sys.inspect(fields);
- res.writeHead(200, {
- "content-type" : "text/plain",
- "content-length" : response.length
- });
- res.write(response);
- res.close();
- })
- });
-
-
-### Nested Multipart Messages
-
-Nested multipart parsing is supported. The `stream.part` object always refers
-to the current part. If `part.isMultiPart` is set, then that part is a
-multipart message, which contains other parts. You can inspect its `parts`
-array to see the list of sub-parts, which may also be multipart, and contain
-sub-parts.
## TCP
Oops, something went wrong.

0 comments on commit 94644d7

Please sign in to comment.