diff --git a/AUTHORS b/AUTHORS index 49c312f5387..f89a11276a6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,3 +27,4 @@ David Gomez Nikolaus Graf Alexandre Ardhuin Victor Berchet +Roel Spilker \ No newline at end of file diff --git a/pkg/http/lib/src/base_request.dart b/pkg/http/lib/src/base_request.dart index f54e757f0a6..dab055b4e09 100644 --- a/pkg/http/lib/src/base_request.dart +++ b/pkg/http/lib/src/base_request.dart @@ -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 = {}; + : 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 diff --git a/pkg/http/pubspec.yaml b/pkg/http/pubspec.yaml index 03288ec7428..3821bb0521b 100644 --- a/pkg/http/pubspec.yaml +++ b/pkg/http/pubspec.yaml @@ -1,5 +1,5 @@ name: http -version: 0.9.2+3 +version: 0.9.3-dev author: "Dart Team " homepage: https://pub.dartlang.org/packages/http description: A composable, Future-based API for making HTTP requests. diff --git a/pkg/http/test/request_test.dart b/pkg/http/test/request_test.dart index 929cc636f02..08e2ef95165 100644 --- a/pkg/http/test/request_test.dart +++ b/pkg/http/test/request_test.dart @@ -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);