mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
Send Http auth without waiting for challenge.
This commit is contained in:
parent
70494c3674
commit
2d96914bfa
@ -41,13 +41,6 @@ public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies)
|
||||
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 @@ public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies)
|
||||
headerStream.Write(b, 0, s * n);
|
||||
return s * n;
|
||||
};
|
||||
|
||||
|
||||
curlEasy.Url = request.Url.FullUri;
|
||||
switch (request.Method)
|
||||
{
|
||||
|
@ -15,18 +15,12 @@ public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies)
|
||||
//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 @@ public HttpRequest(string url, HttpAccept httpAccept = null)
|
||||
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 @@ protected virtual void Apply(HttpRequest request)
|
||||
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…
Reference in New Issue
Block a user