Skip to content

Commit c29e881

Browse files
committed
Prepare for 0.15 release
1 parent ea52136 commit c29e881

File tree

5 files changed

+52
-24
lines changed

5 files changed

+52
-24
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.15.0
2+
3+
Released on Friday, April 23 2021.
4+
5+
- Added option to specify default request headers (#29)
6+
- Fixed unhandled exceptions that may break the requester (#28)
7+
18
# 0.14.0
29

310
Released on Tuesday, March 31 2020.

src/AngleSharp.Io.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<copyright>Copyright 2016-2021, AngleSharp</copyright>
1515
<tags>html html5 css css3 dom requester http https io filesystem storage httpclient cache</tags>
1616
<dependencies>
17-
<dependency id="AngleSharp" version="0.14.0" />
17+
<dependency id="AngleSharp" version="0.15.0" />
1818
</dependencies>
1919
</metadata>
2020
</package>

src/AngleSharp.Io/AngleSharp.Io.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="AngleSharp" Version="0.14.0" />
24+
<PackageReference Include="AngleSharp" Version="0.15.0" />
2525
</ItemGroup>
2626

2727
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">

src/AngleSharp.Io/Network/HttpClientRequester.cs

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ public HttpClientRequester(HttpClient client)
4141

4242
#endregion
4343

44+
#region Properties
45+
46+
/// <summary>
47+
/// Gets the used HttpClient for further manipulation.
48+
/// </summary>
49+
public HttpClient Client => _client;
50+
51+
#endregion
52+
4453
#region Methods
4554

4655
/// <summary>
@@ -92,36 +101,48 @@ protected override async Task<IResponse> PerformRequestAsync(Request request, Ca
92101
}
93102
}
94103

95-
// execute the request
96-
var responseMessage = await _client.SendAsync(requestMessage, cancel).ConfigureAwait(false);
97-
98-
// convert the response
99-
var response = new DefaultResponse
104+
try
100105
{
101-
Headers = responseMessage.Headers.ToDictionary(p => p.Key, p => String.Join(", ", p.Value)),
102-
Address = Url.Convert(responseMessage.RequestMessage.RequestUri),
103-
StatusCode = responseMessage.StatusCode
104-
};
106+
// execute the request
107+
var responseMessage = await _client.SendAsync(requestMessage, cancel).ConfigureAwait(false);
105108

106-
// get the anticipated content
107-
var content = responseMessage.Content;
109+
// convert the response
110+
var response = new DefaultResponse
111+
{
112+
Headers = responseMessage.Headers.ToDictionary(p => p.Key, p => String.Join(", ", p.Value)),
113+
Address = Url.Convert(responseMessage.RequestMessage.RequestUri),
114+
StatusCode = responseMessage.StatusCode
115+
};
108116

109-
if (content != null)
110-
{
111-
response.Content = await content.ReadAsStreamAsync().ConfigureAwait(false);
117+
// get the anticipated content
118+
var content = responseMessage.Content;
112119

113-
foreach (var pair in content.Headers)
120+
if (content != null)
114121
{
115-
response.Headers[pair.Key] = String.Join(", ", pair.Value);
122+
response.Content = await content.ReadAsStreamAsync().ConfigureAwait(false);
123+
124+
foreach (var pair in content.Headers)
125+
{
126+
response.Headers[pair.Key] = String.Join(", ", pair.Value);
127+
}
128+
}
129+
130+
if (IsRedirected(response) && !response.Headers.ContainsKey(HeaderNames.SetCookie))
131+
{
132+
response.Headers[HeaderNames.SetCookie] = String.Empty;
116133
}
117-
}
118134

119-
if (IsRedirected(response) && !response.Headers.ContainsKey(HeaderNames.SetCookie))
135+
return response;
136+
}
137+
catch (Exception)
120138
{
121-
response.Headers[HeaderNames.SetCookie] = String.Empty;
139+
// create a response to avoid failing (#28)
140+
return new DefaultResponse
141+
{
142+
Address = Url.Convert(request.Address),
143+
StatusCode = 0
144+
};
122145
}
123-
124-
return response;
125146
}
126147

127148
private static Boolean IsRedirected(IResponse response)

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<PropertyGroup>
33
<Description>Providers additional requesters and IO helpers for AngleSharp.</Description>
44
<Product>AngleSharp.Io</Product>
5-
<Version>0.14.0</Version>
5+
<Version>0.15.0</Version>
66
</PropertyGroup>
77
</Project>

0 commit comments

Comments
 (0)