Readded logging Download Client responses.

pull/6/head
Taloth Saldono 9 years ago
parent 9f34127565
commit cc0406653a

@ -81,6 +81,11 @@ namespace NzbDrone.Common.Http
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 ||

@ -36,6 +36,7 @@ namespace NzbDrone.Common.Http
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; }

@ -21,6 +21,7 @@ namespace NzbDrone.Common.Http
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 @@ namespace NzbDrone.Common.Http
request.SuppressHttpError = SuppressHttpError;
request.AllowAutoRedirect = AllowAutoRedirect;
request.ConnectionKeepAlive = ConnectionKeepAlive;
request.LogResponseContent = LogResponseContent;
if (NetworkCredential != null)
{

@ -163,14 +163,15 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{
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 @@ namespace NzbDrone.Core.Download.Clients.Deluge
_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)

@ -116,7 +116,10 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
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)

@ -155,10 +155,11 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
{
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

@ -138,6 +138,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
.Accept(HttpAccept.Json)
.AddQueryParam("mode", mode);
requestBuilder.LogResponseContent = true;
if (settings.ApiKey.IsNotNullOrWhiteSpace())
{
requestBuilder.AddSuffixQueryParam("apikey", settings.ApiKey);

@ -180,6 +180,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
.Resource("rpc")
.Accept(HttpAccept.Json);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
requestBuilder.AllowAutoRedirect = false;

@ -129,6 +129,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
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;

@ -162,6 +162,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
.SetHeader("Cache-Control", "no-cache")
.Accept(HttpAccept.Json);
requestBuilder.LogResponseContent = true;
requestBuilder.NetworkCredential = new NetworkCredential(settings.Username, settings.Password);
return requestBuilder;

Loading…
Cancel
Save