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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 var request = new HttpRequestMessage(HttpMethod.Get, location); | 125 var request = new HttpRequestMessage(HttpMethod.Get, location); |
126 request.Headers.IfModifiedSince = new DateTimeOffset(DateTime.No
w); | 126 request.Headers.IfModifiedSince = new DateTimeOffset(DateTime.No
w); |
127 request.Headers.IfUnmodifiedSince = new DateTimeOffset(DateTime.
Now); | 127 request.Headers.IfUnmodifiedSince = new DateTimeOffset(DateTime.
Now); |
128 request.Headers.IfMatch.Add(new EntityTagHeaderValue("\"a\"")); | 128 request.Headers.IfMatch.Add(new EntityTagHeaderValue("\"a\"")); |
129 request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue("\"b\""
)); | 129 request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue("\"b\""
)); |
130 | 130 |
131 HttpResponseMessage response = client.SendAsync(request).Result; | 131 HttpResponseMessage response = client.SendAsync(request).Result; |
132 | 132 |
133 Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Redir
ect)); | 133 Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Redir
ect)); |
134 Assert.That(response.Headers.Location, Is.EqualTo( | 134 Assert.That(response.Headers.Location, Is.EqualTo( |
135 new Uri(location configurableHanlder.NumRedirects))); | 135 new Uri(location (configurableHanlder.NumRedirects 1))))
; |
136 Assert.That(redirectHandler.Calls, Is.EqualTo(configurableHanlde
r.NumRedirects)); | 136 Assert.That(redirectHandler.Calls, Is.EqualTo(configurableHanlde
r.NumRedirects 1)); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 /// <summary>· | 140 /// <summary>· |
141 /// Tests that the message handler doesn't handle redirect messages when
follow redirect is <c>false</c>.· | 141 /// Tests that the message handler doesn't handle redirect messages when
follow redirect is <c>false</c>.· |
142 /// </summary> | 142 /// </summary> |
143 [Test] | 143 [Test] |
144 public void SendAsync_Redirect_FollowRedirectFalse() | 144 public void SendAsync_Redirect_FollowRedirectFalse() |
145 { | 145 { |
146 const int tries = 12; | 146 const int tries = 12; |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 // with application name | 1012 // with application name |
1013 configurableHanlder.ApplicationName = applicationName; | 1013 configurableHanlder.ApplicationName = applicationName; |
1014 request = new HttpRequestMessage(HttpMethod.Get, "https://test-u
ser-agent"); | 1014 request = new HttpRequestMessage(HttpMethod.Get, "https://test-u
ser-agent"); |
1015 response = client.SendAsync(request).Result; | 1015 response = client.SendAsync(request).Result; |
1016 userAgent = string.Join(" ", request.Headers.GetValues("User-Age
nt").ToArray()); | 1016 userAgent = string.Join(" ", request.Headers.GetValues("User-Age
nt").ToArray()); |
1017 Assert.That(userAgent, Is.EqualTo(applicationName " " apiVer
sion)); | 1017 Assert.That(userAgent, Is.EqualTo(applicationName " " apiVer
sion)); |
1018 } | 1018 } |
1019 } | 1019 } |
1020 } | 1020 } |
1021 } | 1021 } |
LEFT | RIGHT |