diff --git a/CHANGELOG.md b/CHANGELOG.md index ea2df3d..82c264f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.2 + +* Fix computation of the audience given to metadata providers to include the scheme. + ## 2.0.1 * Fix computation of authority. This should fix authorization. diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 0e1eb56..3085378 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -150,7 +150,7 @@ class ClientCall implements Response { Future.forEach( options.metadataProviders, (provider) => provider( - metadata, "${connection.authority}${audiencePath(_method)}")) + metadata, '${connection.scheme}://${connection.authority}${audiencePath(_method)}')) .then((_) => _sendRequest(connection, _sanitizeMetadata(metadata))) .catchError(_onMetadataProviderError); } diff --git a/lib/src/client/connection.dart b/lib/src/client/connection.dart index b6c829d..baec80f 100644 --- a/lib/src/client/connection.dart +++ b/lib/src/client/connection.dart @@ -38,6 +38,7 @@ enum ConnectionState { abstract class ClientConnection { String get authority; + String get scheme; /// Put [call] on the queue to be dispatched when the connection is ready. void dispatchCall(ClientCall call); diff --git a/lib/src/client/http2_connection.dart b/lib/src/client/http2_connection.dart index a4d8c9c..c6b0df4 100644 --- a/lib/src/client/http2_connection.dart +++ b/lib/src/client/http2_connection.dart @@ -65,6 +65,8 @@ class Http2ClientConnection implements connection.ClientConnection { String get authority => options.credentials.authority ?? (port == 443 ? host : "$host:$port"); + String get scheme => options.credentials.isSecure ? 'https' : 'http'; + ConnectionState get state => _state; Future connectTransport() async { diff --git a/lib/src/client/transport/xhr_transport.dart b/lib/src/client/transport/xhr_transport.dart index f0e6eea..ad89caf 100644 --- a/lib/src/client/transport/xhr_transport.dart +++ b/lib/src/client/transport/xhr_transport.dart @@ -143,6 +143,7 @@ class XhrClientConnection extends ClientConnection { XhrClientConnection(this.uri); String get authority => uri.authority; + String get scheme => uri.scheme; void _initializeRequest(HttpRequest request, Map metadata) { for (final header in metadata.keys) { diff --git a/pubspec.yaml b/pubspec.yaml index 3e7ce7b..44d9dd1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: grpc description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. -version: 2.0.1 +version: 2.0.2 author: Dart Team homepage: https://github.com/dart-lang/grpc-dart