Fixed: Now sends appropriate http Accept header to indexer.

This commit is contained in:
Taloth Saldono 2014-09-14 11:47:46 +02:00
parent 525f1aa9dd
commit b3f086fe93
3 changed files with 87 additions and 10 deletions

View file

@ -57,6 +57,8 @@ namespace NzbDrone.Common.Test.Http
var exception = Assert.Throws<HttpException>(() => Subject.Get<HttpBinResource>(request));
exception.Response.StatusCode.Should().Be(statusCode);
ExceptionVerification.IgnoreWarns();
}
@ -66,20 +68,39 @@ namespace NzbDrone.Common.Test.Http
{
var request = new HttpRequest("http://eu.httpbin.org/status/" + (int)statusCode);
Assert.Throws<Exception>(() => Subject.Get<HttpBinResource>(request));
Assert.Throws<Exception>(() => Subject.Get<HttpBinResource>(request));
}
[Test]
public void should_send_user_agent()
{
var request = new HttpRequest("http://eu.httpbin.org/get");
var response = Subject.Get<HttpBinResource>(request);
response.Resource.Headers.Should().ContainKey("User-Agent");
var userAgent = response.Resource.Headers["User-Agent"].ToString();
userAgent.Should().Contain("NzbDrone");
}
[TestCase("Accept", "text/xml, text/rss+xml, application/rss+xml")]
public void should_send_headers(String header, String value)
{
var request = new HttpRequest("http://eu.httpbin.org/get");
request.Headers.Add(header, value);
var response = Subject.Get<HttpBinResource>(request);
response.Resource.Headers[header].ToString().Should().Be(value);
}
}
public class HttpBinResource
{
public Dictionary<string, object> Headers { get; set; }
public string Origin { get; set; }
public string Url { get; set; }
}
}