@@ -17,26 +17,27 @@ public static IClient Create(
17
17
ISerializerService serializerService ,
18
18
ITokenProvider tokenProvider ,
19
19
bool readResponseAsStream = false ,
20
- ICorrelationIdProvider correlationIdProvider = null )
20
+ ICorrelationIdProvider correlationIdProvider = null ,
21
+ Version httpVersion = null )
21
22
{
22
23
Validator . ValidateObject ( configuration , new ValidationContext ( configuration ) , true ) ;
23
24
if ( readResponseAsStream && serializerService is IStreamSerializerService streamSerializer )
24
25
{
25
26
return new StreamCtpClient (
26
- CreateMiddlewareStack ( clientName , configuration , factory , tokenProvider , true , correlationIdProvider ) ,
27
+ CreateMiddlewareStack ( clientName , configuration , factory , tokenProvider , true , correlationIdProvider , httpVersion ) ,
27
28
streamSerializer ,
28
29
clientName
29
30
) ;
30
31
}
31
32
return new CtpClient (
32
- CreateMiddlewareStack ( clientName , configuration , factory , tokenProvider , false , correlationIdProvider ) ,
33
+ CreateMiddlewareStack ( clientName , configuration , factory , tokenProvider , false , correlationIdProvider , httpVersion ) ,
33
34
serializerService ,
34
35
clientName
35
36
) ;
36
37
}
37
38
38
39
public static Middleware CreateMiddlewareStack ( string clientName , IClientConfiguration configuration ,
39
- IHttpClientFactory factory , ITokenProvider tokenProvider , bool readResponseAsStream = false , ICorrelationIdProvider correlationIdProvider = null )
40
+ IHttpClientFactory factory , ITokenProvider tokenProvider , bool readResponseAsStream = false , ICorrelationIdProvider correlationIdProvider = null , Version httpVersion = null )
40
41
{
41
42
var httpClient = factory . CreateClient ( clientName ) ;
42
43
httpClient . BaseAddress = new Uri ( configuration . ApiBaseAddress ) ;
@@ -48,6 +49,10 @@ public static Middleware CreateMiddlewareStack(string clientName, IClientConfigu
48
49
correlationIdProvider ?? new DefaultCorrelationIdProvider ( configuration )
49
50
)
50
51
} ;
52
+ if ( httpVersion != null )
53
+ {
54
+ handlers . Add ( CreateVersionMiddleware ( httpVersion ) ) ;
55
+ }
51
56
52
57
var httpMiddleware =
53
58
readResponseAsStream ? ( DelegatingMiddleware ) new StreamHttpMiddleware ( httpClient ) : new HttpMiddleware ( httpClient ) ;
@@ -70,5 +75,10 @@ public static CorrelationIdMiddleware CreateCorrelationIdMiddleware(
70
75
{
71
76
return new CorrelationIdMiddleware ( correlationIdProvider ) ;
72
77
}
78
+
79
+ public static VersionMiddleware CreateVersionMiddleware ( Version httpVersion )
80
+ {
81
+ return new VersionMiddleware ( httpVersion ) ;
82
+ }
73
83
}
74
84
}
0 commit comments