Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1054)

Unified Diff: sdk/lib/io/http_multipart_form_data.dart

Issue 14796015: Add new HttpMultipartFormData, used for parsing a MimeMultipart and extracting either text or binar… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update doc comments. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_headers.dart ('k') | sdk/lib/io/http_multipart_form_data_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_multipart_form_data.dart
diff --git a/sdk/lib/io/http_multipart_form_data.dart b/sdk/lib/io/http_multipart_form_data.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3c9bca41507703661ac83e6b79f6ab4c76f1b102
--- /dev/null
+++ b/sdk/lib/io/http_multipart_form_data.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.io;
+
+
+/**
+ * [:HttpMultipartFormData:] class used for 'upgrading' a [MimeMultipart] by
+ * parsing it as a 'multipart/form-data' part. The following code shows how
+ * it can be used.
+ *
+ * HttpServer server = ...;
+ * server.listen((request) {
+ * String boundary = request.headers.contentType.parameters['boundary'];
+ * request
+ * .transform(new MimeMultipartTransformer(boundary))
+ * .map(HttpMultipartFormData.parse)
+ * .map((HttpMultipartFormData formData) {
+ * // form data object available here.
+ * });
+ *
+ * [:HttpMultipartFormData:] is a Stream, serving either bytes or decoded
+ * Strings. Use [isText] or [isBinary] to see what type of data is provided.
+ */
+abstract class HttpMultipartFormData implements Stream {
+ /**
+ * The parsed [:Content-Type:] header of the [:HttpMultipartFormData:].
+ * Returns [:null:] if not present.
+ */
+ ContentType get contentType;
+
+ /**
+ * The parsed [:Content-Disposition:] header of the [:HttpMultipartFormData:].
+ * This field is always present. Use this to extract e.g. name(form field
+ * name)and filename (client provided name of uploaded file) parameters.
+ */
+ HeaderValue get contentDisposition;
+
+ /**
+ * The parsed [:Content-Transfer-Encoding:] header of the
+ * [:HttpMultipartFormData:]. This field is used to determine how to decode
+ * the data. Returns [:null:] if not present.
+ */
+ HeaderValue get contentTransferEncoding;
+
+ /**
+ * Returns [:true:] if the data is decoded as [String].
+ */
+ bool get isText;
+
+ /**
+ * Returns [:true:] if the data is raw bytes.
+ */
+ bool get isBinary;
+
+ /**
+ * Returns the value for the header named [name]. If there
+ * is no header with the provided name, [:null:] will be returned.
+ *
+ * Use this method to index other headers available in the original
+ * [MimeMultipart].
+ */
+ String value(String name);
+
+ /**
+ * Parse a [MimeMultipart] and return a [HttpMultipartFormData]. If the
+ * [:Content-Disposition:] header is missing or invalid, a [HttpException] is
+ * thrown.
+ */
+ static HttpMultipartFormData parse(MimeMultipart multipart)
+ => _HttpMultipartFormData.parse(multipart);
+}
« no previous file with comments | « sdk/lib/io/http_headers.dart ('k') | sdk/lib/io/http_multipart_form_data_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698