Content-Type header is now stored with a case insensitive key.

Actually, all headers are. Added test that failed before this fix.

BUG=17405
R=nweiz@google.com

Review URL: https://codereview.chromium.org//198423002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33635 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
nweiz@google.com 2014-03-13 01:36:04 +00:00
parent 429d0aef98
commit e47cf1319c
4 changed files with 14 additions and 3 deletions

View file

@ -27,3 +27,4 @@ David Gomez <irisindigo@gmail.com>
Nikolaus Graf <nik@blossom.io>
Alexandre Ardhuin <alexandre.ardhuin@gmail.com>
Victor Berchet <victor.berchet@gmail.com>
Roel Spilker <r.spilker@gmail.com>

View file

@ -5,6 +5,7 @@
library base_request;
import 'dart:async';
import 'dart:collection';
import 'byte_stream.dart';
import 'client.dart';
@ -79,7 +80,9 @@ abstract class BaseRequest {
/// Creates a new HTTP request.
BaseRequest(this.method, this.url)
: headers = <String, String>{};
: headers = new LinkedHashMap(
equals: (key1, key2) => key1.toLowerCase() == key2.toLowerCase(),
hashCode: (key) => key.toLowerCase().hashCode);
/// Finalizes the HTTP request in preparation for it being sent. This freezes
/// all mutable fields and returns a single-subscription [ByteStream] that

View file

@ -1,5 +1,5 @@
name: http
version: 0.9.2+3
version: 0.9.3-dev
author: "Dart Team <misc@dartlang.org>"
homepage: https://pub.dartlang.org/packages/http
description: A composable, Future-based API for making HTTP requests.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// 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.
@ -271,6 +271,13 @@ void main() {
expect(request.headers[HttpHeaders.CONTENT_TYPE], isNull);
});
test('name is case insensitive', () {
var request = new http.Request('POST', dummyUrl);
request.headers['CoNtEnT-tYpE'] = 'application/json';
expect(request.headers,
containsPair('content-type', 'application/json'));
});
test('is set to application/x-www-form-urlencoded with charset utf-8 if '
'bodyFields is set', () {
var request = new http.Request('POST', dummyUrl);