|
|
|
@ -149,7 +149,7 @@ namespace Grpc.Core |
|
|
|
|
/// </summary> |
|
|
|
|
protected internal class ClientBaseConfiguration |
|
|
|
|
{ |
|
|
|
|
private class ClientHeaderInterceptor : Interceptor |
|
|
|
|
private class ClientHeaderInterceptor : GenericInterceptor |
|
|
|
|
{ |
|
|
|
|
readonly Func<IMethod, string, CallOptions, Tuple<string, CallOptions>> interceptor; |
|
|
|
|
|
|
|
|
@ -161,49 +161,13 @@ namespace Grpc.Core |
|
|
|
|
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, "interceptor"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Intercepts a blocking invocation of a simple remote call. |
|
|
|
|
/// </summary> |
|
|
|
|
public override TResponse BlockingUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, BlockingUnaryCallContinuation<TRequest, TResponse> continuation) |
|
|
|
|
{ |
|
|
|
|
var newHeaders = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return continuation(request, new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHeaders.Item1, newHeaders.Item2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Intercepts an asynchronous invocation of a simple remote call. |
|
|
|
|
/// </summary> |
|
|
|
|
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, AsyncUnaryCallContinuation<TRequest, TResponse> continuation) |
|
|
|
|
{ |
|
|
|
|
var newHeaders = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return continuation(request, new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHeaders.Item1, newHeaders.Item2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Intercepts an asynchronous invocation of a streaming remote call. |
|
|
|
|
/// </summary> |
|
|
|
|
public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, AsyncServerStreamingCallContinuation<TRequest, TResponse> continuation) |
|
|
|
|
{ |
|
|
|
|
var newHeaders = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return continuation(request, new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHeaders.Item1, newHeaders.Item2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Intercepts an asynchronous invocation of a client streaming call. |
|
|
|
|
/// </summary> |
|
|
|
|
public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, AsyncClientStreamingCallContinuation<TRequest, TResponse> continuation) |
|
|
|
|
{ |
|
|
|
|
var newHeaders = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return continuation(new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHeaders.Item1, newHeaders.Item2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Intercepts an asynchronous invocation of a duplex streaming call. |
|
|
|
|
/// </summary> |
|
|
|
|
public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, AsyncDuplexStreamingCallContinuation<TRequest, TResponse> continuation) |
|
|
|
|
protected override ClientCallArbitrator<TRequest, TResponse> InterceptCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, bool clientStreaming, bool serverStreaming, TRequest request) |
|
|
|
|
{ |
|
|
|
|
var newHeaders = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return continuation(new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHeaders.Item1, newHeaders.Item2)); |
|
|
|
|
var newHostAndCallOptions = interceptor(context.Method, context.Host, context.Options); |
|
|
|
|
return new ClientCallArbitrator<TRequest, TResponse> |
|
|
|
|
{ |
|
|
|
|
Context = new ClientInterceptorContext<TRequest, TResponse>(context.Method, newHostAndCallOptions.Item1, newHostAndCallOptions.Item2) |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|