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

Issue 10407002: Add special handling of the content type HTTP header (Closed)

Created:
8 years, 7 months ago by Søren Gjesse
Modified:
8 years, 7 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add special handling of the content type HTTP header This adds parsing of HTTP headers of the form: Name=value; parameter1=value1; parameter2=value2 Specialize the implemented header value class into a content type class. One could argue whether the "synchronization" between the string representation and the content type object representation is the best way, but if the exposed parameters map should just be the standard map implementation there is no way of detection changes, R=ager@google.com, ajohnsen@google.com BUG=dart:2045 TEST=tests/standalone/io/http_test.dart, tests/standalone/io/http_headers_test.dart Committed: https://code.google.com/p/dart/source/detail?r=7851

Patch Set 1 #

Total comments: 82

Patch Set 2 : Addressed review comments #

Total comments: 4

Patch Set 3 : Removed the content type caching to simplify. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+488 lines, -2 lines) Patch
M runtime/bin/http.dart View 1 2 2 chunks +118 lines, -2 lines 0 comments Download
M runtime/bin/http_impl.dart View 1 2 4 chunks +179 lines, -0 lines 0 comments Download
M tests/standalone/io/http_headers_test.dart View 1 1 chunk +111 lines, -0 lines 0 comments Download
M tests/standalone/io/http_test.dart View 1 2 4 chunks +80 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Søren Gjesse
8 years, 7 months ago (2012-05-16 15:13:23 UTC) #1
Anders Johnsen
LGTM! http://codereview.chromium.org/10407002/diff/1/runtime/bin/http.dart File runtime/bin/http.dart (right): http://codereview.chromium.org/10407002/diff/1/runtime/bin/http.dart#newcode306 runtime/bin/http.dart:306: ContentType contentType; IMO, this is a good way ...
8 years, 7 months ago (2012-05-21 07:37:30 UTC) #2
Mads Ager (google)
https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http.dart File runtime/bin/http.dart (right): https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http.dart#newcode315 runtime/bin/http.dart:315: interface HeaderValue default _HeaderValue { Should we expose this ...
8 years, 7 months ago (2012-05-21 07:40:39 UTC) #3
Anders Johnsen
https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http_impl.dart File runtime/bin/http_impl.dart (right): https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http_impl.dart#newcode40 runtime/bin/http_impl.dart:40: if (name == "content-type") contentType == null; =, not ...
8 years, 7 months ago (2012-05-21 07:43:21 UTC) #4
Søren Gjesse
Thanks for all the comments - PTAL. http://codereview.chromium.org/10407002/diff/1/runtime/bin/http.dart File runtime/bin/http.dart (right): http://codereview.chromium.org/10407002/diff/1/runtime/bin/http.dart#newcode306 runtime/bin/http.dart:306: ContentType contentType; ...
8 years, 7 months ago (2012-05-21 11:11:05 UTC) #5
Anders Johnsen
http://codereview.chromium.org/10407002/diff/1/runtime/bin/http_impl.dart File runtime/bin/http_impl.dart (right): http://codereview.chromium.org/10407002/diff/1/runtime/bin/http_impl.dart#newcode397 runtime/bin/http_impl.dart:397: if (index == -1 || s.length == index - ...
8 years, 7 months ago (2012-05-21 11:27:03 UTC) #6
Mads Ager (google)
LGTM Considering immutable header values could still be a good idea to avoid tracking changes ...
8 years, 7 months ago (2012-05-21 11:49:33 UTC) #7
Søren Gjesse
8 years, 7 months ago (2012-05-22 12:47:16 UTC) #8
Ended up removing the caching of the parsed content type. Now it is recreated
from the string on each access and setting it will change the header string
directly.

https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http_impl....
File runtime/bin/http_impl.dart (right):

https://chromiumcodereview.appspot.com/10407002/diff/1/runtime/bin/http_impl....
runtime/bin/http_impl.dart:397: if (index == -1 || s.length == index - 1) {
On 2012/05/21 11:27:03, ajohnsen wrote:
> On 2012/05/21 11:11:06, Søren Gjesse wrote:
> > On 2012/05/21 07:37:30, ajohnsen wrote:
> > > Did you mean 'index == s.length - 1'?
> > 
> > No, this is either not found or last char.
> 
> But the last char is the case where index is s.length - 1? What we have not is
> either not found or index == s.length + 1, two chars after the end. That, or
> brain meltdown here :)

My brain meltdown - sorry for being stupid.

https://chromiumcodereview.appspot.com/10407002/diff/9001/runtime/bin/http_im...
File runtime/bin/http_impl.dart (right):

https://chromiumcodereview.appspot.com/10407002/diff/9001/runtime/bin/http_im...
runtime/bin/http_impl.dart:404: if (index == -1 || s.length == index - 1) {
On 2012/05/21 11:49:33, Mads Ager wrote:
> I agree with Anders about this being: index == (s.length - 1)
> 
> However, it will probably work without that check because the substring for
the
> subType below will be the empty string. :-)

Of cause you are both right.

https://chromiumcodereview.appspot.com/10407002/diff/9001/tests/standalone/io...
File tests/standalone/io/http_test.dart (right):

https://chromiumcodereview.appspot.com/10407002/diff/9001/tests/standalone/io...
tests/standalone/io/http_test.dart:560: Expect.equals("utf-8",
response.headers.contentType.parameters["charset"]);
On 2012/05/21 11:49:33, Mads Ager wrote:
> Long line.

Done.

Powered by Google App Engine
This is Rietveld 408576698