LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /// Gets or sets a HTTP client initializer which is able to customiz
e properties on· | 71 /// Gets or sets a HTTP client initializer which is able to customiz
e properties on· |
72 /// <see cref="Google.Apis.Http.ConfigurableHttpClient"/> and· | 72 /// <see cref="Google.Apis.Http.ConfigurableHttpClient"/> and· |
73 /// <see cref="Google.Apis.Http.ConfigurableMessageHandler"/>. | 73 /// <see cref="Google.Apis.Http.ConfigurableMessageHandler"/>. |
74 /// </summary> | 74 /// </summary> |
75 public IConfigurableHttpClientInitializer HttpClientInitializer { ge
t; set; } | 75 public IConfigurableHttpClientInitializer HttpClientInitializer { ge
t; set; } |
76 | 76 |
77 /// <summary> | 77 /// <summary> |
78 /// Get or sets the exponential back-off policy used by the service.
Default value is· | 78 /// Get or sets the exponential back-off policy used by the service.
Default value is· |
79 /// <c>UnsuccessfulResponse503</c>, which means that exponential bac
k-off is used on 503 abnormal HTTP | 79 /// <c>UnsuccessfulResponse503</c>, which means that exponential bac
k-off is used on 503 abnormal HTTP |
80 /// response. | 80 /// response. |
81 /// If the value is set to <c>None</c>, no exponential back-off poli
cy is used, and it's up to user to | 81 /// If the value is set to <c>None</c>, no exponential back-off poli
cy is used, and it's up to the user to |
82 /// configure the <seealso cref="Google.Apis.Http.ConfigurableMessag
eHandler"/> in an | 82 /// configure the <seealso cref="Google.Apis.Http.ConfigurableMessag
eHandler"/> in an |
83 /// <seealso cref="Google.Apis.Http.IConfigurableHttpClientInitializ
er"/> to set a specific back-off | 83 /// <seealso cref="Google.Apis.Http.IConfigurableHttpClientInitializ
er"/> to set a specific back-off |
84 /// implementation (using <seealso cref="Google.Apis.Http.BackOffHan
dler"/>). | 84 /// implementation (using <seealso cref="Google.Apis.Http.BackOffHan
dler"/>). |
85 /// </summary> | 85 /// </summary> |
86 public ExponentialBackOffPolicy DefaultExponentialBackOffPolicy { ge
t; set; } | 86 public ExponentialBackOffPolicy DefaultExponentialBackOffPolicy { ge
t; set; } |
87 | 87 |
88 /// <summary>Gets or sets whether this service supports GZip. Defaul
t value is <c>true</c>.</summary> | 88 /// <summary>Gets or sets whether this service supports GZip. Defaul
t value is <c>true</c>.</summary> |
89 public bool GZipEnabled { get; set; } | 89 public bool GZipEnabled { get; set; } |
90 | 90 |
91 /// <summary> | 91 /// <summary> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Add exponential back-off initializer if necessary. | 170 // Add exponential back-off initializer if necessary. |
171 if (initializer.DefaultExponentialBackOffPolicy != ExponentialBackOf
fPolicy.None) | 171 if (initializer.DefaultExponentialBackOffPolicy != ExponentialBackOf
fPolicy.None) |
172 { | 172 { |
173 args.Initializers.Add(new ExponentialBackOffInitializer(initiali
zer.DefaultExponentialBackOffPolicy, | 173 args.Initializers.Add(new ExponentialBackOffInitializer(initiali
zer.DefaultExponentialBackOffPolicy, |
174 CreateBackOffHandler)); | 174 CreateBackOffHandler)); |
175 } | 175 } |
176 | 176 |
177 // Add authenticator initializer to intercept a request and add the
"Authorization" header and also handle | 177 // Add authenticator initializer to intercept a request and add the
"Authorization" header and also handle |
178 // abnormal 401 responses in case the authenticator is an instance o
f unsuccessful response handler. | 178 // abnormal 401 responses in case the authenticator is an instance o
f unsuccessful response handler. |
179 args.Initializers.Add(new AuthenticatorMessageHandlerInitializer(Aut
henticator)); | 179 args.Initializers.Add(new AuthenticatorMessageHandlerInitializer(Aut
henticator)); |
180 | 180 |
181 var httpClient = factory.CreateHttpClient(args); | 181 var httpClient = factory.CreateHttpClient(args); |
182 if (initializer.MaxUrlLength > 0) | 182 if (initializer.MaxUrlLength > 0) |
183 { | 183 { |
184 httpClient.MessageHandler.ExecuteInterceptors.Add( | 184 httpClient.MessageHandler.ExecuteInterceptors.Add( |
185 new MaxUrlLengthInterceptor(initializer.MaxUrlLength)); | 185 new MaxUrlLengthInterceptor(initializer.MaxUrlLength)); |
186 } | 186 } |
187 return httpClient; | 187 return httpClient; |
188 } | 188 } |
189 | 189 |
190 /// <summary> | 190 /// <summary> |
191 /// Creates the back-off handler with <seealso cref="Google.Apis.Util.Ex
ponentialBackOff"/>.· | 191 /// Creates the back-off handler with <seealso cref="Google.Apis.Util.Ex
ponentialBackOff"/>.· |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 public virtual void Dispose() | 376 public virtual void Dispose() |
377 { | 377 { |
378 if (HttpClient != null) | 378 if (HttpClient != null) |
379 { | 379 { |
380 HttpClient.Dispose(); | 380 HttpClient.Dispose(); |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
LEFT | RIGHT |