parent
3d8cd9616e
commit
442d49046d
|
@ -76,5 +76,12 @@ namespace NzbDrone.Common.Http
|
||||||
var encoding = HttpHeader.GetEncodingFromContentType(Headers.ContentType);
|
var encoding = HttpHeader.GetEncodingFromContentType(Headers.ContentType);
|
||||||
ContentData = encoding.GetBytes(data);
|
ContentData = encoding.GetBytes(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddBasicAuthentication(string username, string password)
|
||||||
|
{
|
||||||
|
var authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{username}:{password}"));
|
||||||
|
|
||||||
|
Headers.Set("Authorization", "Basic " + authInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Rest;
|
using NzbDrone.Core.Rest;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Notifications.Webhook
|
namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
|
@ -30,6 +31,10 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
request.Headers.ContentType = "application/json";
|
request.Headers.ContentType = "application/json";
|
||||||
request.SetContent(body.ToJson());
|
request.SetContent(body.ToJson());
|
||||||
|
|
||||||
|
if (settings.Username.IsNotNullOrWhiteSpace() || settings.Password.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
request.AddBasicAuthentication(settings.Username, settings.Password);
|
||||||
|
}
|
||||||
_httpClient.Execute(request);
|
_httpClient.Execute(request);
|
||||||
}
|
}
|
||||||
catch (RestException ex)
|
catch (RestException ex)
|
||||||
|
|
|
@ -29,6 +29,12 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
[FieldDefinition(1, Label = "Method", Type = FieldType.Select, SelectOptions = typeof(WebhookMethod), HelpText = "Which HTTP method to use submit to the Webservice")]
|
[FieldDefinition(1, Label = "Method", Type = FieldType.Select, SelectOptions = typeof(WebhookMethod), HelpText = "Which HTTP method to use submit to the Webservice")]
|
||||||
public int Method { get; set; }
|
public int Method { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(2, Label = "Username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(3, Label = "Password", Type = FieldType.Password)]
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
|
Loading…
Reference in New Issue