Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/93'
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Oct 7, 2014
2 parents e44cf1c + 3b668ce commit ffdb1c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ModernHttpClient/Android/OkHttpNetworkHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
var resp = default(Response);
try {
resp = await call.EnqueueAsync().ConfigureAwait(false);
var newReq = resp.Request();
var newUri = newReq == null ? null : newReq.Uri();
if (throwOnCaptiveNetwork && newUri != null) {
if (url.Host != newUri.Host) {
throw new CaptiveNetworkException(new Uri(java_uri), new Uri(newUri.ToString()));
}
}
} catch (IOException ex) {
if (ex.Message.ToLowerInvariant().Contains("canceled")) {
throw new OperationCanceledException();
Expand All @@ -103,6 +110,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
cancellationToken.ThrowIfCancellationRequested();

var ret = new HttpResponseMessage((HttpStatusCode)resp.Code());
ret.ReasonPhrase = resp.Message();
if (respBody != null) {
var content = new ProgressStreamContent(respBody.ByteStream(), cancellationToken);
content.Progress = getAndRemoveCallbackFromRegister(request);
Expand Down
1 change: 1 addition & 0 deletions src/ModernHttpClient/ModernHttpClient.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<HintPath>..\..\vendor\okhttp\OkHttp.dll</HintPath>
</Reference>
<Compile Include="Utility.cs" />
<Compile Include="CaptiveNetworkException.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
</Project>

0 comments on commit ffdb1c4

Please sign in to comment.