diff --git a/links/gql_http_link/CHANGELOG.md b/links/gql_http_link/CHANGELOG.md index 53361927..6ba5b562 100644 --- a/links/gql_http_link/CHANGELOG.md +++ b/links/gql_http_link/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.10 + +- add `headers` to `HttpLinkResponseContext` + ## 0.2.9 - remove `author` field from `pubspec.yaml` diff --git a/links/gql_http_link/lib/src/link.dart b/links/gql_http_link/lib/src/link.dart index b59cbbf9..b5ea8bda 100644 --- a/links/gql_http_link/lib/src/link.dart +++ b/links/gql_http_link/lib/src/link.dart @@ -32,13 +32,19 @@ class HttpLinkResponseContext extends ContextEntry { /// HTTP status code of the response final int statusCode; + /// HTTP response headers + final Map headers; + const HttpLinkResponseContext({ @required this.statusCode, - }) : assert(statusCode != null); + @required this.headers, + }) : assert(statusCode != null), + assert(headers != null); @override List get fieldsForEquality => [ statusCode, + headers, ]; } @@ -113,6 +119,7 @@ class HttpLink extends Link { return response.context.withEntry( HttpLinkResponseContext( statusCode: httpResponse.statusCode, + headers: httpResponse.headers, ), ); } catch (e) { diff --git a/links/gql_http_link/pubspec.yaml b/links/gql_http_link/pubspec.yaml index b5a3a7f7..d730dea2 100644 --- a/links/gql_http_link/pubspec.yaml +++ b/links/gql_http_link/pubspec.yaml @@ -1,5 +1,5 @@ name: gql_http_link -version: 0.2.9 +version: 0.2.10 description: GQL Terminating Link to execute requests via HTTP using JSON. repository: https://github.com/gql-dart/gql environment: diff --git a/links/gql_http_link/test/gql_http_link_test.dart b/links/gql_http_link/test/gql_http_link_test.dart index e79e50ea..6c9cce15 100644 --- a/links/gql_http_link/test/gql_http_link_test.dart +++ b/links/gql_http_link/test/gql_http_link_test.dart @@ -57,6 +57,7 @@ void main() { "data": {}, }), 200, + headers: {"header-1": "value-1"}, ), ), ); @@ -72,7 +73,10 @@ void main() { ResponseExtensions(null), ) .withEntry( - HttpLinkResponseContext(statusCode: 200), + HttpLinkResponseContext( + statusCode: 200, + headers: const {"header-1": "value-1"}, + ), ), ), emitsDone, @@ -361,6 +365,7 @@ void main() { }, ), 200, + headers: {"header-1": "value-1"}, ), ), ); @@ -385,7 +390,10 @@ void main() { ResponseExtensions(null), ) .withEntry( - HttpLinkResponseContext(statusCode: 200), + HttpLinkResponseContext( + statusCode: 200, + headers: const {"header-1": "value-1"}, + ), ), ), emitsDone,