1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Readded logging Download Client responses.

This commit is contained in:
Taloth Saldono 2016-04-06 22:53:14 +02:00
parent 9f34127565
commit cc0406653a
10 changed files with 28 additions and 9 deletions

View File

@ -81,6 +81,11 @@ public HttpResponse Execute(HttpRequest request)
response = interceptor.PostResponse(response);
}
if (request.LogResponseContent)
{
_logger.Trace("Response content ({0} bytes): {1}", response.ResponseData.Length, response.Content);
}
if (!RuntimeInfoBase.IsProduction &&
(response.StatusCode == HttpStatusCode.Moved ||
response.StatusCode == HttpStatusCode.MovedPermanently ||

View File

@ -36,6 +36,7 @@ public HttpRequest(string url, HttpAccept httpAccept = null)
public bool SuppressHttpError { get; set; }
public bool AllowAutoRedirect { get; set; }
public bool ConnectionKeepAlive { get; set; }
public bool LogResponseContent { get; set; }
public Dictionary<string, string> Cookies { get; private set; }
public bool StoreResponseCookie { get; set; }
public TimeSpan RequestTimeout { get; set; }

View File

@ -21,6 +21,7 @@ public class HttpRequestBuilder
public bool SuppressHttpError { get; set; }
public bool AllowAutoRedirect { get; set; }
public bool ConnectionKeepAlive { get; set; }
public bool LogResponseContent { get; set; }
public NetworkCredential NetworkCredential { get; set; }
public Dictionary<string, string> Cookies { get; private set; }
public List<HttpFormData> FormData { get; private set; }
@ -100,6 +101,7 @@ protected virtual void Apply(HttpRequest request)
request.SuppressHttpError = SuppressHttpError;
request.AllowAutoRedirect = AllowAutoRedirect;
request.ConnectionKeepAlive = ConnectionKeepAlive;
request.LogResponseContent = LogResponseContent;
if (NetworkCredential != null)
{

View File

@ -163,14 +163,15 @@ private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
{
string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
var builder = new JsonRpcRequestBuilder(url);
var requestBuilder = new JsonRpcRequestBuilder(url);
requestBuilder.LogResponseContent = true;
builder.Resource("json");
builder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15);
requestBuilder.Resource("json");
requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15);
AuthenticateClient(builder, settings);
AuthenticateClient(requestBuilder, settings);
return builder;
return requestBuilder;
}
protected TResult ProcessRequest<TResult>(DelugeSettings settings, string method, params object[] arguments)
@ -255,6 +256,7 @@ private void AuthenticateClient(JsonRpcRequestBuilder requestBuilder, DelugeSett
_authCookieCache.Remove(authKey);
var authLoginRequest = requestBuilder.Call("auth.login", settings.Password).Build();
authLoginRequest.ContentSummary = "auth.login(\"(removed)\")";
var response = _httpClient.Execute(authLoginRequest);
var result = Json.Deserialize<JsonRpcResponse<bool>>(response.Content);
if (!result.Result)

View File

@ -116,7 +116,10 @@ public List<NzbVortexFile> GetFiles(int id, NzbVortexSettings settings)
private HttpRequestBuilder BuildRequest(NzbVortexSettings settings)
{
return new HttpRequestBuilder(true, settings.Host, settings.Port, "api");
var requestBuilder = new HttpRequestBuilder(true, settings.Host, settings.Port, "api");
requestBuilder.LogResponseContent = true;
return requestBuilder;
}
private T ProcessRequest<T>(HttpRequestBuilder requestBuilder, bool requiresAuthentication, NzbVortexSettings settings)

View File

@ -155,10 +155,11 @@ private T ProcessRequest<T>(NzbgetSettings settings, string method, params objec
{
var baseUrl = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, "jsonrpc");
var builder = new JsonRpcRequestBuilder(baseUrl, method, parameters);
builder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
var requestBuilder = new JsonRpcRequestBuilder(baseUrl, method, parameters);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
var httpRequest = builder.Build();
var httpRequest = requestBuilder.Build();
HttpResponse response;
try

View File

@ -138,6 +138,8 @@ private HttpRequestBuilder BuildRequest(string mode, SabnzbdSettings settings)
.Accept(HttpAccept.Json)
.AddQueryParam("mode", mode);
requestBuilder.LogResponseContent = true;
if (settings.ApiKey.IsNotNullOrWhiteSpace())
{
requestBuilder.AddSuffixQueryParam("apikey", settings.ApiKey);

View File

@ -180,6 +180,7 @@ private HttpRequestBuilder BuildRequest(TransmissionSettings settings)
.Resource("rpc")
.Accept(HttpAccept.Json);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
requestBuilder.AllowAutoRedirect = false;

View File

@ -129,6 +129,7 @@ public void MoveTorrentToTopInQueue(string hash, QBittorrentSettings settings)
private HttpRequestBuilder BuildRequest(QBittorrentSettings settings)
{
var requestBuilder = new HttpRequestBuilder(settings.UseSsl, settings.Host, settings.Port);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
return requestBuilder;

View File

@ -162,6 +162,7 @@ private HttpRequestBuilder BuildRequest(UTorrentSettings settings)
.SetHeader("Cache-Control", "no-cache")
.Accept(HttpAccept.Json);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
return requestBuilder;