Skip to content

Commit 08aae94

Browse files
Add Uri fix
1 parent dad07ba commit 08aae94

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/HtmlAgilityPack.Shared/HtmlWeb.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,20 @@ public async Task<HtmlDocument> LoadFromWebAsync(Uri uri, Encoding encoding, Net
24002400
var e = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false);
24012401
_statusCode = e.StatusCode;
24022402

2403+
if(e.Headers != null && e.Headers.Location != null)
2404+
{
2405+
if(e.Headers.Location.IsAbsoluteUri)
2406+
{
2407+
_responseUri = new Uri(e.Headers.Location.AbsoluteUri);
2408+
}
2409+
else
2410+
{
2411+
#if !(NETSTANDARD1_3 || NETSTANDARD1_6 || WINDOWS_UWP)
2412+
_responseUri = new Uri(uri.GetLeftPart(UriPartial.Authority) + e.Headers.Location);
2413+
#endif
2414+
}
2415+
}
2416+
24032417
var html = string.Empty;
24042418
if (encoding != null)
24052419
{

0 commit comments

Comments
 (0)