Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing query string / file upoad support (e.g. in http post) #2488

Open
DartBot opened this issue Apr 8, 2012 · 16 comments
Open

missing query string / file upoad support (e.g. in http post) #2488

DartBot opened this issue Apr 8, 2012 · 16 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 8, 2012

This issue was originally filed by is...@google.com


a HTTP POST body might contain:

  • file upload
  • encoded query string
  • other multipart content

We need library support to deal with these inputs on the server side

@kasperl
Copy link

kasperl commented Apr 11, 2012

Added Area-IO, Triaged labels.

@madsager
Copy link
Contributor

Set owner to @sgjesse.
Added Accepted label.

@sgjesse
Copy link
Contributor

sgjesse commented Apr 17, 2012

Having support for the different ways form data can be delivered is definitely important. To get started with the handling of multipart content I suggest that we make a multipart MIME parser available. Here is a suggested interface:

/**
 * MIME multipart parser.
 *
 * This parser can read data from a stream.
 /
interface MultipartParser {
  /**
   
Construct a new MIME multipart parser providing the boundary string.
   */
  MultipartParser(InputStream stream, String boundary);

  /**
   * Sets callback to be called for each multipart.
   */
  void onPart(MultipartPart part);

  /**
   * Sets callback to be called when the final part has been processed.
   */
  onDone()

  /**
   * Sets callback to be called when an error occours.
   */
  onError(Exception e)
}

interface MultipartPart {
  /**
   * Returns the headers for this part.
   */
  MultipartHeaders get headers();

  /**
   * Returns the stream where the data for this part can be read.
   */
  InputStream get stream;
}

interface MultipartHeaders {
  List<String> operator[](String name);

  String contentType;
  Map<String, String> contentTypeParameters;
  String contentDisposition;
  Map<String, String> contentDispositionParameters
}

With this library Handling a form posted as multipart/form-data (only containing input fields -
not file data) in a HTTP request could look like this:

  var form = new Map();
  var multipart = new MultipartParser(request.inputStream, boundary);
  multipart.onPart = (MultipartPart part) {
    assert(headers.contentDisposition == "form-data");
    name = part.headers.contentDispositionParameters["name"];
    Encoding encoding = ... // Get the encoding from the MIME headers.
    StreamUtils.readStreamToString(part.stream,
                                   encoding),
                                   (String value) => form[name] = value,
                                   (e) => ...);
  }
  multipart.onDone() {
    // Form content is now in the Map form.
  }
  multipart.onError(e) {
    ...
  }

Of cause this handling of the message body should be easily accessible in the HTTP library.

This uses a new library function that we plan to add:

  void StreamUtils.readStreamToString(InputStream stream,
                                      Encoding encoding,
                                      Function callback,
                                      [Function error]);

@sgjesse
Copy link
Contributor

sgjesse commented May 24, 2012

Added Started label.

@madsager
Copy link
Contributor

madsager commented Jun 7, 2012

Added this to the M1 milestone.

@sgjesse
Copy link
Contributor

sgjesse commented Jun 8, 2012

Issue #3439 has been merged into this issue.

@sgjesse
Copy link
Contributor

sgjesse commented Jun 8, 2012

From merged issue #3439:

The server need to provide a way for handling FORM POST. As a FORM POST is special handling of the HTTP request body this should probably a request handler and not built into the HttpRequest object.

This handler should handle both content types:

  application/x-www-form-urlencoded
  multipart/form-data

The _MimeMultipartParser is already in runtime/bin/mime_multipart_parser.dart to parse a multipart/form-data body.

@sethladd
Copy link
Contributor

Removed this from the M1 milestone.
Added this to the Later milestone.

@sgjesse
Copy link
Contributor

sgjesse commented Dec 5, 2012

Issue #7154 has been merged into this issue.

@sgjesse
Copy link
Contributor

sgjesse commented Dec 5, 2012

Issue #6952 has been merged into this issue.

@sethladd
Copy link
Contributor

sethladd commented Dec 5, 2012

See also package http://pub.dartlang.org/packages/query_string

@nex3
Copy link
Member

nex3 commented Mar 20, 2013

Marked this as blocking #7391.

@sgjesse
Copy link
Contributor

sgjesse commented Apr 16, 2013

Added Duplicate label.
Marked as being merged into #8834.

@sgjesse
Copy link
Contributor

sgjesse commented Apr 16, 2013

Unmarked this as blocking #7391.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io closed-duplicate Closed in favor of an existing report labels May 14, 2014
@DartBot DartBot added this to the Later milestone May 14, 2014
dart-bot pushed a commit that referenced this issue May 20, 2020
Includes the following changes:
a4bc2dd08630f85a94f506eab037fcaaedb42222 Rename --v2 to --dart-dev-run (#2498)
958862efa33605af3136c4bd366015bace62d869 Update outdated.dart (#2488)
2cc09730f73204afced1df606416c07d5ee1e67d outdated: work with no lock file (#2491)
7c73dae26df2b3ef3e3019d7296fd2871dd23c49 Do not fallback to bin/main.dart (#2478)
27bc4f7ef65928c95535baf51245fd5b01162d0f Preserve windows line endings in pubspec.lock if they are already there (#2489)
31cfec521db6fe607f0f0424e747dff2e4950711 pub outdated --mode=null-safety
da05bbaee8c53b769d1f90458e28b3b7f9a22187 Fix `pub run` precompilation with relative PUB_CACHE paths (#2486)
dd005e586fc17545f22fc6e75eedfc9f075f9092 Show summary count of outdated packages after running `pub upgrade`  (#2444)
1b927956e653ea74a153513e593ff417617cabf0 Outdated: If current is a prerelease, use prereleases for latest if no newer stable (#2484)
678bd84a328fabb3fee360f837ac782f2831d753 Warn first time a package version opts in to null-safety (#2465)
8e76d46a4b8180ab247ecf6382f4f7abd34591f1 Force colors when --color is given (#2481)
572a23f815a5d632a8c2b259b691792674cd8b4d Rely on terminal telling if we can use colors (#2475)
363ed6fe54c084df43bbec1704757d0d6c64cbb7 pub run --v2 for use in dartdev (#2435)
aa5bbbb7261fc492866b5d6b94357cbe8df5e09a Use a 8-bit ansi palette for grey (#2474)
3929b1138a589b4f506018d98b3005a3e76dcea6 Format with new dartfmt (#2476)
6deb457048deb435009b36a4cd2d86003d107cf4 Use line length to wrap usage (#2457)
6e2ce2e4add80c4e15c8346a976cbf760d707f6a Use gzip decoder from dart:io. (#2382)
5b5fe72a33a66e4cab7070b3248596877e3a854e Improve the `pub outdated --help` text (#2429)

Change-Id: If9a719bfc374f085bd26856330547682c14f0df4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148532
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
@sigurdm sigurdm reopened this Mar 13, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Mar 13, 2023

I think this was closed by mistake by the commit above.

@lrhn lrhn added type-enhancement A request for a change that isn't a bug and removed closed-duplicate Closed in favor of an existing report labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants