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 |
11 distributed under the License is distributed on an "AS IS" BASIS, | 11 distributed under the License is distributed on an "AS IS" BASIS, |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 See the License for the specific language governing permissions and | 13 See the License for the specific language governing permissions and |
14 limitations under the License. | 14 limitations under the License. |
15 */ | 15 */ |
16 | 16 |
17 using System; | 17 using System; |
18 using System.Net.Http; | 18 using System.Net.Http; |
19 using System.Threading; | 19 using System.Threading; |
20 using System.Threading.Tasks; | 20 using System.Threading.Tasks; |
21 | 21 |
22 namespace Google.Apis.Http | 22 namespace Google.Apis.Http |
23 { | 23 { |
24 /// <summary> Argument class to <see cref="IHttpExceptionHandler.HandleExcep
tionAsync"/>.</summary> | 24 /// <summary>Argument class to <see cref="IHttpExceptionHandler.HandleExcept
ionAsync"/>.</summary> |
25 public class HandleExceptionArgs | 25 public class HandleExceptionArgs |
26 { | 26 { |
27 /// <summary> Gets or sets the sent request.</summary> | 27 /// <summary>Gets or sets the sent request.</summary> |
28 public HttpRequestMessage Request { get; set; } | 28 public HttpRequestMessage Request { get; set; } |
29 | 29 |
30 /// <summary> Gets or sets the exception which occurred during sending t
he request.</summary> | 30 /// <summary>Gets or sets the exception which occurred during sending th
e request.</summary> |
31 public Exception Exception { get; set; } | 31 public Exception Exception { get; set; } |
32 | 32 |
33 /// <summary> Gets or sets the total number of tries to send the request
.</summary> | 33 /// <summary>Gets or sets the total number of tries to send the request.
</summary> |
34 public int TotalTries { get; set; } | 34 public int TotalTries { get; set; } |
35 | 35 |
36 /// <summary> Gets or sets the current failed try.</summary> | 36 /// <summary>Gets or sets the current failed try.</summary> |
37 public int CurrentFailedTry { get; set; } | 37 public int CurrentFailedTry { get; set; } |
38 | 38 |
39 /// <summary> Gets whether there will actually be a retry if the handler
returns <c>true</c>.</summary> | 39 /// <summary>Gets whether there will actually be a retry if the handler
returns <c>true</c>.</summary> |
40 public bool SupportsRetry | 40 public bool SupportsRetry |
41 { | 41 { |
42 get { return TotalTries - CurrentFailedTry > 0; } | 42 get { return TotalTries - CurrentFailedTry > 0; } |
43 } | 43 } |
44 | 44 |
45 /// <summary> Gets and sets the cancellation token which belongs to the
request.</summary> | 45 /// <summary>Gets and sets the cancellation token which belongs to the r
equest.</summary> |
46 public CancellationToken CancellationToken { get; set; } | 46 public CancellationToken CancellationToken { get; set; } |
47 } | 47 } |
48 | 48 |
49 /// <summary> | 49 /// <summary> |
50 /// Exception handler which is invoked when an exception is thrown during a
HTTP request. | 50 /// Exception handler which is invoked when an exception is thrown during a
HTTP request. |
51 /// </summary> | 51 /// </summary> |
52 public interface IHttpExceptionHandler | 52 public interface IHttpExceptionHandler |
53 { | 53 { |
54 /// <summary> | 54 /// <summary> |
55 /// Handles an exception thrown when sending a HTTP request.· | 55 /// Handles an exception thrown when sending a HTTP request.· |
56 /// A simple rule must be followed, if you modify the request object in
a way that the exception can be· | 56 /// A simple rule must be followed, if you modify the request object in
a way that the exception can be· |
57 /// resolved, you must return <c>true</c>. | 57 /// resolved, you must return <c>true</c>. |
58 /// </summary> | 58 /// </summary> |
59 /// <param name="args"> | 59 /// <param name="args"> |
60 /// Handle exception argument which contains properties like the request
, the exception, current failed try. | 60 /// Handle exception argument which contains properties like the request
, the exception, current failed try. |
61 /// </param> | 61 /// </param> |
62 /// <returns>Whether or not this handler has made a change that will req
uire the request to be resent</returns> | 62 /// <returns>Whether or not this handler has made a change that will req
uire the request to be resent</returns> |
63 Task<bool> HandleExceptionAsync(HandleExceptionArgs args); | 63 Task<bool> HandleExceptionAsync(HandleExceptionArgs args); |
64 } | 64 } |
65 } | 65 } |
LEFT | RIGHT |