Send Http auth without waiting for challenge.

pull/3113/head
Taloth Saldono 9 years ago
parent 70494c3674
commit 2d96914bfa

@ -41,13 +41,6 @@ namespace NzbDrone.Common.Http.Dispatchers
throw new ApplicationException("Curl failed to initialize.");
}
if (request.NetworkCredential != null)
{
var authInfo = request.NetworkCredential.UserName + ":" + request.NetworkCredential.Password;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
request.Headers["Authorization"] = "Basic " + authInfo;
}
lock (CurlGlobalHandle.Instance)
{
Stream responseStream = new MemoryStream();
@ -66,7 +59,7 @@ namespace NzbDrone.Common.Http.Dispatchers
headerStream.Write(b, 0, s * n);
return s * n;
};
curlEasy.Url = request.Url.FullUri;
switch (request.Method)
{

@ -15,18 +15,12 @@ namespace NzbDrone.Common.Http.Dispatchers
//http://stackoverflow.com/questions/8490718/how-to-decompress-stream-deflated-with-java-util-zip-deflater-in-net
webRequest.AutomaticDecompression = DecompressionMethods.GZip;
webRequest.Credentials = request.NetworkCredential;
webRequest.Method = request.Method.ToString();
webRequest.UserAgent = UserAgentBuilder.UserAgent;
webRequest.KeepAlive = false;
webRequest.AllowAutoRedirect = request.AllowAutoRedirect;
webRequest.CookieContainer = cookies;
if (request.NetworkCredential != null)
{
webRequest.PreAuthenticate = true;
}
if (request.RequestTimeout != TimeSpan.Zero)
{
webRequest.Timeout = (int)Math.Ceiling(request.RequestTimeout.TotalMilliseconds);

@ -33,7 +33,6 @@ namespace NzbDrone.Common.Http
public HttpHeader Headers { get; set; }
public byte[] ContentData { get; set; }
public string ContentSummary { get; set; }
public NetworkCredential NetworkCredential { get; set; }
public bool SuppressHttpError { get; set; }
public bool AllowAutoRedirect { get; set; }
public Dictionary<string, string> Cookies { get; private set; }

@ -98,7 +98,13 @@ namespace NzbDrone.Common.Http
request.Method = Method;
request.SuppressHttpError = SuppressHttpError;
request.AllowAutoRedirect = AllowAutoRedirect;
request.NetworkCredential = NetworkCredential;
if (NetworkCredential != null)
{
var authInfo = NetworkCredential.UserName + ":" + NetworkCredential.Password;
authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(authInfo));
request.Headers.Set("Authorization", "Basic " + authInfo);
}
foreach (var header in Headers)
{

Loading…
Cancel
Save