LEFT | RIGHT |
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 /// <summary> Number of tries. Default is <c>3</c>. </summary> | 87 /// <summary> Number of tries. Default is <c>3</c>. </summary> |
88 private int numTries = 3; | 88 private int numTries = 3; |
89 | 89 |
90 /// <summary>· | 90 /// <summary>· |
91 /// Gets or sets the number of tries that will be allowed to execute. Re
tries occur as a result of either | 91 /// Gets or sets the number of tries that will be allowed to execute. Re
tries occur as a result of either |
92 /// <see cref="IHttpUnsuccessfulResponseHandler"/> or <see cref="IHttpEx
ceptionHandler"/> which handles the | 92 /// <see cref="IHttpUnsuccessfulResponseHandler"/> or <see cref="IHttpEx
ceptionHandler"/> which handles the |
93 /// abnormal Http response or exception, before being terminated.· | 93 /// abnormal Http response or exception, before being terminated.· |
94 /// Set <c>1</c> for not retrying requests. The default value is <c>3</c
>". | 94 /// Set <c>1</c> for not retrying requests. The default value is <c>3</c
>". |
95 /// <remarks> | 95 /// <remarks> |
96 /// The number of allowed redirects (3xx) is defined by <seealso cref="N
umRedirects"/>. This property defines | 96 /// The number of allowed redirects (3xx) is defined by <seealso cref="N
umRedirects"/>. This property defines |
97 /// only the allowed tries of >=400 responses, or a case an exception wa
s thrown. | 97 /// only the allowed tries for >=400 responses, or in a case an exceptio
n was thrown. For example you set· |
| 98 /// <see cref="NumTries"/> to 1 and <see cref="NumRedirect"/> to 5, a re
try will happen only for 5 redirects. |
98 /// </remarks> | 99 /// </remarks> |
99 /// </summary> | 100 /// </summary> |
100 public int NumTries | 101 public int NumTries |
101 { | 102 { |
102 get { return numTries; } | 103 get { return numTries; } |
103 set | 104 set |
104 { | 105 { |
105 if (value > MaxAllowedNumTries || value < 1) | 106 if (value > MaxAllowedNumTries || value < 1) |
106 { | 107 { |
107 throw new ArgumentOutOfRangeException("NumTries"); | 108 throw new ArgumentOutOfRangeException("NumTries"); |
108 } | 109 } |
109 numTries = value; | 110 numTries = value; |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 /// <summary> Number of redirects allowed. Default is <c>10</c>. </summa
ry> | 114 /// <summary> Number of redirects allowed. Default is <c>10</c>. </summa
ry> |
114 private int numRedirect = 10; | 115 private int numRedirect = 10; |
115 | 116 |
116 /// <summary>· | 117 /// <summary>· |
117 /// Gets or sets the number of redirects that will be allowed to execute
. The default value is <c>10</c>. | 118 /// Gets or sets the number of redirects that will be allowed to execute
. The default value is <c>10</c>. |
| 119 /// See <see cref="NumTries"/> for more information. |
118 /// </summary> | 120 /// </summary> |
119 public int NumRedirects | 121 public int NumRedirects |
120 { | 122 { |
121 get { return numRedirect; } | 123 get { return numRedirect; } |
122 set | 124 set |
123 { | 125 { |
124 if (value > MaxAllowedNumTries || value < 1) | 126 if (value > MaxAllowedNumTries || value < 1) |
125 { | 127 { |
126 throw new ArgumentOutOfRangeException("NumRedirects"); | 128 throw new ArgumentOutOfRangeException("NumRedirects"); |
127 } | 129 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 TotalTries = NumTries, | 260 TotalTries = NumTries, |
259 CurrentFailedTry = NumTries - triesRemaining
, | 261 CurrentFailedTry = NumTries - triesRemaining
, |
260 CancellationToken = cancellationToken | 262 CancellationToken = cancellationToken |
261 }); | 263 }); |
262 } | 264 } |
263 | 265 |
264 if (!errorHandled) | 266 if (!errorHandled) |
265 { | 267 { |
266 if (HandleRedirect(response)) | 268 if (HandleRedirect(response)) |
267 { | 269 { |
268 redirectRemaining--; | 270 if (redirectRemaining-- == 0) |
269 if (redirectRemaining == 0) | |
270 { | 271 { |
271 triesRemaining = 0; | 272 triesRemaining = 0; |
272 } | 273 } |
273 | 274 |
274 errorHandled = true; | 275 errorHandled = true; |
275 if (loggable) | 276 if (loggable) |
276 { | 277 { |
277 Logger.Debug("Redirect response was handled
successfully. Redirect to {0}", | 278 Logger.Debug("Redirect response was handled
successfully. Redirect to {0}", |
278 response.Headers.Location); | 279 response.Headers.Location); |
279 } | 280 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 request.Headers.Remove("Authorization"); | 341 request.Headers.Remove("Authorization"); |
341 request.Headers.IfMatch.Clear(); | 342 request.Headers.IfMatch.Clear(); |
342 request.Headers.IfNoneMatch.Clear(); | 343 request.Headers.IfNoneMatch.Clear(); |
343 request.Headers.IfModifiedSince = null; | 344 request.Headers.IfModifiedSince = null; |
344 request.Headers.IfUnmodifiedSince = null; | 345 request.Headers.IfUnmodifiedSince = null; |
345 request.Headers.Remove("If-Range"); | 346 request.Headers.Remove("If-Range"); |
346 return true; | 347 return true; |
347 } | 348 } |
348 } | 349 } |
349 } | 350 } |
LEFT | RIGHT |