Fixed header request.
This commit is contained in:
parent
233def11c7
commit
a997c10ca1
|
@ -6,12 +6,12 @@ using NzbDrone.Test.Common;
|
|||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class WebClientTests : TestBase
|
||||
public class WebClientTests : TestBase<HttpProvider>
|
||||
{
|
||||
[Test]
|
||||
public void DownloadString_should_be_able_to_dowload_text_file()
|
||||
{
|
||||
var jquery = new HttpProvider(new EnvironmentProvider()).DownloadString("http://www.google.com/robots.txt");
|
||||
var jquery = Subject.DownloadString("http://www.google.com/robots.txt");
|
||||
|
||||
jquery.Should().NotBeBlank();
|
||||
jquery.Should().Contain("Sitemap");
|
||||
|
@ -23,7 +23,15 @@ namespace NzbDrone.Common.Test
|
|||
[ExpectedException]
|
||||
public void DownloadString_should_throw_on_error(string url)
|
||||
{
|
||||
var jquery = new HttpProvider(new EnvironmentProvider()).DownloadString(url);
|
||||
var jquery = Subject.DownloadString(url);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_get_headers()
|
||||
{
|
||||
Subject.GetHeader("http://www.google.com").Should().NotBeEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Common
|
|||
string DownloadString(string address);
|
||||
string DownloadString(string address, string username, string password);
|
||||
string DownloadString(string address, ICredentials identity);
|
||||
Dictionary<string, string> DownloadHeader(string url);
|
||||
Dictionary<string, string> GetHeader(string url);
|
||||
|
||||
Stream DownloadStream(string url, NetworkCredential credential = null);
|
||||
void DownloadFile(string url, string fileName);
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Common
|
|||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, string> DownloadHeader(string url)
|
||||
public Dictionary<string, string> GetHeader(string url)
|
||||
{
|
||||
var headers = new Dictionary<string, string>();
|
||||
var request = WebRequest.Create(url);
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Common
|
|||
|
||||
var response = request.GetResponse();
|
||||
|
||||
foreach (var key in headers.Keys)
|
||||
foreach (var key in response.Headers.AllKeys)
|
||||
{
|
||||
headers.Add(key, response.Headers[key]);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
{
|
||||
_headers = new Dictionary<string, string>();
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFileSize(It.IsAny<string>())).Returns(100);
|
||||
Mocker.GetMock<IHttpProvider>().Setup(c => c.DownloadHeader(It.IsAny<string>())).Returns(_headers);
|
||||
Mocker.GetMock<IHttpProvider>().Setup(c => c.GetHeader(It.IsAny<string>())).Returns(_headers);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace NzbDrone.Core.MediaCover
|
|||
return false;
|
||||
}
|
||||
|
||||
var headers = _httpProvider.DownloadHeader(url);
|
||||
var headers = _httpProvider.GetHeader(url);
|
||||
|
||||
string sizeString;
|
||||
|
||||
|
|
Loading…
Reference in New Issue