mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-28 23:06:43 -04:00
Use modern HttpClient
(cherry picked from commit 402f8b296f17bf161824ec5ff40d67d036d00d94)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -8,25 +9,30 @@ namespace NzbDrone.Integration.Test
|
||||
[TestFixture]
|
||||
public class IndexHtmlFixture : IntegrationTest
|
||||
{
|
||||
private HttpClient _httpClient = new HttpClient();
|
||||
|
||||
[Test]
|
||||
public void should_get_index_html()
|
||||
{
|
||||
var text = new WebClient().DownloadString(RootUrl);
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, RootUrl);
|
||||
var response = _httpClient.Send(request);
|
||||
var text = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
text.Should().NotBeNullOrWhiteSpace();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void index_should_not_be_cached()
|
||||
{
|
||||
var client = new WebClient();
|
||||
_ = client.DownloadString(RootUrl);
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, RootUrl);
|
||||
var response = _httpClient.Send(request);
|
||||
|
||||
var headers = client.ResponseHeaders;
|
||||
var headers = response.Headers;
|
||||
|
||||
headers.Get("Cache-Control").Split(',').Select(x => x.Trim())
|
||||
.Should().BeEquivalentTo("no-store, no-cache".Split(',').Select(x => x.Trim()));
|
||||
headers.Get("Pragma").Should().Be("no-cache");
|
||||
headers.Get("Expires").Should().Be("-1");
|
||||
headers.CacheControl.NoStore.Should().BeTrue();
|
||||
headers.CacheControl.NoCache.Should().BeTrue();
|
||||
headers.Pragma.Should().Contain(new NameValueHeaderValue("no-cache"));
|
||||
|
||||
response.Content.Headers.Expires.Should().BeBefore(DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user