diff --git a/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs b/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs index 8b7bac6..8a4fd62 100644 --- a/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs +++ b/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs @@ -90,6 +90,13 @@ protected override async Task 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(); @@ -103,6 +110,7 @@ protected override async Task 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); diff --git a/src/ModernHttpClient/ModernHttpClient.Android.csproj b/src/ModernHttpClient/ModernHttpClient.Android.csproj index 1c8e4e9..5c6b8a0 100644 --- a/src/ModernHttpClient/ModernHttpClient.Android.csproj +++ b/src/ModernHttpClient/ModernHttpClient.Android.csproj @@ -58,6 +58,7 @@ ..\..\vendor\okhttp\OkHttp.dll +