Skip to content

http headers Content-Type problems #15

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

Closed
DartBot opened this issue Jun 5, 2015 · 5 comments
Closed

http headers Content-Type problems #15

DartBot opened this issue Jun 5, 2015 · 5 comments
Labels
closed-duplicate Closed in favor of an existing report type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

Originally opened as dart-lang/sdk#17405

This issue was originally filed by [email protected]


A Content-Type header is ignored when sending http.post.

If I call http.post with a header "Content-Type", the server doesn't get the value specified if there is also a body. Instead, it always gets "text/plain; charset=utf-8".

If I change the header key to "content-type", everything works as expected.

There are several issues here.

  1. I would expect the header key to be used case-insensitive.
  2. Requests set body has as side-effect that the _contentType is set.

This side-effect is documented, however it explicitly mentions "Content-Type". And so does Requests ContentType get \_contentType.

I've attached two source files to demonstrate the problem.


Attachments:
httpheadersserver.dart (288 Bytes)
httpheadersclient.dart (243 Bytes)
pubspec.yaml (91 Bytes)

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl


Added Area-IO, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This comment was originally written by [email protected]


I think the problem is in base_request.dart:

 BaseRequest(this.method, this.url)
    : headers = <String, String>{};

This map is not case-insensitive, it should be. A few lines higher, I've found the following comment:

  // TODO(nweiz): make this a HttpHeaders object
  /// The headers for this request.
  final Map<String, String> headers;

I tried to figure out if I could make a patch, but I encountered two problems:

  • I don't understand how I would be able to use the LinkedHashMap external factory that accepts alternative equality and hash functions for keys
  • Currently I can't build all dart projects on my machine

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/22043?v=3" align="left" width="48" height="48"hspace="10"> Comment by skabet


I'm re-assigning, as this is the http package, and not dart:io directly.

Thanks for filing this!


Removed Area-IO label.
Added Area-pkg, Pkg-Http labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This comment was originally written by [email protected]


Created a patch: https://codereview.chromium.org/198423002

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

1 participant