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.Net.Http; | 17 using System.Net.Http; |
18 using System.Threading; | 18 using System.Threading; |
19 using System.Threading.Tasks; | 19 using System.Threading.Tasks; |
20 | 20 |
21 namespace Google.Apis.Http | 21 namespace Google.Apis.Http |
22 { | 22 { |
23 /// <summary> Argument class to <see cref="IHttpUnsuccessfulResponseHandler.
HandleResponseAsync"/>.</summary> | 23 /// <summary>Argument class to <see cref="IHttpUnsuccessfulResponseHandler.H
andleResponseAsync"/>.</summary> |
24 public class HandleUnsuccessfulResponseArgs | 24 public class HandleUnsuccessfulResponseArgs |
25 { | 25 { |
26 /// <summary> Gets or sets the sent request.</summary> | 26 /// <summary>Gets or sets the sent request.</summary> |
27 public HttpRequestMessage Request { get; set; } | 27 public HttpRequestMessage Request { get; set; } |
28 | 28 |
29 /// <summary> Gets or sets the abnormal response.</summary> | 29 /// <summary>Gets or sets the abnormal response.</summary> |
30 public HttpResponseMessage Response { get; set; } | 30 public HttpResponseMessage Response { get; set; } |
31 | 31 |
32 /// <summary> Gets or sets the total number of tries to send the request
.</summary> | 32 /// <summary>Gets or sets the total number of tries to send the request.
</summary> |
33 public int TotalTries { get; set; } | 33 public int TotalTries { get; set; } |
34 | 34 |
35 /// <summary> Gets or sets the current failed try.</summary> | 35 /// <summary>Gets or sets the current failed try.</summary> |
36 public int CurrentFailedTry { get; set; } | 36 public int CurrentFailedTry { get; set; } |
37 | 37 |
38 /// <summary> Gets whether there will actually be a retry if the handler
returns <c>true</c>.</summary> | 38 /// <summary>Gets whether there will actually be a retry if the handler
returns <c>true</c>.</summary> |
39 public bool SupportsRetry | 39 public bool SupportsRetry |
40 { | 40 { |
41 get { return TotalTries - CurrentFailedTry > 0; } | 41 get { return TotalTries - CurrentFailedTry > 0; } |
42 } | 42 } |
43 | 43 |
44 /// <summary> Gets and sets the cancellation token which belongs to the
request.</summary> | 44 /// <summary>Gets and sets the cancellation token which belongs to the r
equest.</summary> |
45 public CancellationToken CancellationToken { get; set; } | 45 public CancellationToken CancellationToken { get; set; } |
46 } | 46 } |
47 | 47 |
48 /// <summary> | 48 /// <summary> |
49 /// Unsuccessful response handler which is invoked when an abnormal HTTP res
ponse is returned when sending a HTTP | 49 /// Unsuccessful response handler which is invoked when an abnormal HTTP res
ponse is returned when sending a HTTP |
50 /// request. | 50 /// request. |
51 /// </summary> | 51 /// </summary> |
52 public interface IHttpUnsuccessfulResponseHandler | 52 public interface IHttpUnsuccessfulResponseHandler |
53 { | 53 { |
54 /// <summary> | 54 /// <summary> |
55 /// Handles an abnormal response when sending a HTTP request.· | 55 /// Handles an abnormal response when sending a HTTP request.· |
56 /// A simple rule must be followed, if you modify the request object in
a way that the abnormal response can· | 56 /// A simple rule must be followed, if you modify the request object in
a way that the abnormal response can· |
57 /// be resolved, you must return <c>true</c>. | 57 /// be resolved, you must return <c>true</c>. |
58 /// </summary> | 58 /// </summary> |
59 /// <param name="args"> | 59 /// <param name="args"> |
60 /// Handle response argument which contains properties like the request,
the response, current failed try. | 60 /// Handle response argument which contains properties like the request,
the response, 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> HandleResponseAsync(HandleUnsuccessfulResponseArgs args); | 63 Task<bool> HandleResponseAsync(HandleUnsuccessfulResponseArgs args); |
64 } | 64 } |
65 } | 65 } |
LEFT | RIGHT |