From c07b229c9215c6752602fc2004b6b9e5231d445a Mon Sep 17 00:00:00 2001 From: Tavernini Gabriel Date: Sat, 3 Oct 2020 01:07:10 +0200 Subject: [PATCH] Added rawHeaders attribute --- lib/src/base_response.dart | 6 +++++- lib/src/io_streamed_response.dart | 2 ++ lib/src/response.dart | 6 ++++++ lib/src/streamed_response.dart | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/src/base_response.dart b/lib/src/base_response.dart index 5040245fae..c11f149a0c 100644 --- a/lib/src/base_response.dart +++ b/lib/src/base_response.dart @@ -2,8 +2,9 @@ // 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. -import 'base_request.dart'; +import 'dart:io'; +import 'base_request.dart'; /// The base class for HTTP responses. /// /// Subclasses of [BaseResponse] are usually not constructed manually; instead, @@ -28,6 +29,8 @@ abstract class BaseResponse { // TODO(nweiz): make this a HttpHeaders object. final Map headers; + final HttpHeaders? rawHeaders; + final bool isRedirect; /// Whether the server requested that a persistent connection be maintained. @@ -36,6 +39,7 @@ abstract class BaseResponse { BaseResponse(this.statusCode, {this.contentLength, this.request, + this.rawHeaders, this.headers = const {}, this.isRedirect = false, this.persistentConnection = true, diff --git a/lib/src/io_streamed_response.dart b/lib/src/io_streamed_response.dart index 21744858b3..6470e32023 100644 --- a/lib/src/io_streamed_response.dart +++ b/lib/src/io_streamed_response.dart @@ -20,6 +20,7 @@ class IOStreamedResponse extends StreamedResponse { IOStreamedResponse(Stream> stream, int statusCode, {int? contentLength, BaseRequest? request, + HttpHeaders? rawHeaders, Map headers = const {}, bool isRedirect = false, bool persistentConnection = true, @@ -29,6 +30,7 @@ class IOStreamedResponse extends StreamedResponse { super(stream, statusCode, contentLength: contentLength, request: request, + rawHeaders: rawHeaders, headers: headers, isRedirect: isRedirect, persistentConnection: persistentConnection, diff --git a/lib/src/response.dart b/lib/src/response.dart index 01899887a7..122504f443 100644 --- a/lib/src/response.dart +++ b/lib/src/response.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; +import 'dart:io'; import 'dart:typed_data'; import 'package:http_parser/http_parser.dart'; @@ -30,12 +31,14 @@ class Response extends BaseResponse { /// Creates a new HTTP response with a string body. Response(String body, int statusCode, {BaseRequest? request, + HttpHeaders? rawHeaders, Map headers = const {}, bool isRedirect = false, bool persistentConnection = true, String? reasonPhrase}) : this.bytes(_encodingForHeaders(headers).encode(body), statusCode, request: request, + rawHeaders: rawHeaders, headers: headers, isRedirect: isRedirect, persistentConnection: persistentConnection, @@ -44,6 +47,7 @@ class Response extends BaseResponse { /// Create a new HTTP response with a byte array body. Response.bytes(List bodyBytes, int statusCode, {BaseRequest? request, + HttpHeaders? rawHeaders, Map headers = const {}, bool isRedirect = false, bool persistentConnection = true, @@ -52,6 +56,7 @@ class Response extends BaseResponse { super(statusCode, contentLength: bodyBytes.length, request: request, + rawHeaders: rawHeaders, headers: headers, isRedirect: isRedirect, persistentConnection: persistentConnection, @@ -63,6 +68,7 @@ class Response extends BaseResponse { final body = await response.stream.toBytes(); return Response.bytes(body, response.statusCode, request: response.request, + rawHeaders: response.rawHeaders, headers: response.headers, isRedirect: response.isRedirect, persistentConnection: response.persistentConnection, diff --git a/lib/src/streamed_response.dart b/lib/src/streamed_response.dart index e082dced0e..1f846090f3 100644 --- a/lib/src/streamed_response.dart +++ b/lib/src/streamed_response.dart @@ -2,6 +2,8 @@ // 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. +import 'dart:io'; + import 'base_request.dart'; import 'base_response.dart'; import 'byte_stream.dart'; @@ -21,6 +23,7 @@ class StreamedResponse extends BaseResponse { StreamedResponse(Stream> stream, int statusCode, {int? contentLength, BaseRequest? request, + HttpHeaders? rawHeaders, Map headers = const {}, bool isRedirect = false, bool persistentConnection = true, @@ -29,6 +32,7 @@ class StreamedResponse extends BaseResponse { super(statusCode, contentLength: contentLength, request: request, + rawHeaders: rawHeaders, headers: headers, isRedirect: isRedirect, persistentConnection: persistentConnection,