diff --git a/README.md b/README.md
index 920a1ff..b26c5a4 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,9 @@ all websites as if they're not protected with anything.
var handler = new ClearanceHandler("http://localhost:8191/")
{
MaxTimeout = 60000,
- ProxyUrl = "http://127.0.0.1:8888"
+ ProxyUrl = "http://127.0.0.1:8888",
+ ProxyUsername = "cool_username",
+ ProxyPassword = "password4"
};
var client = new HttpClient(handler);
@@ -71,3 +73,13 @@ Example: 60000
The ProxyUrl which will be sent to FlareSolverr.
Example: http://127.0.0.1:8888
+
+### ProxyUsername
+The ProxyUsername which will be sent to FlareSolverr. (Only if ProxyUrl has been set)
+
+Use this if the proxy you're using requires authentication.
+
+### ProxyPassword
+The ProxyPassword which will be sent to FlareSolverr. (Only if ProxyUrl has been set)
+
+Use this if the proxy you're using requires authentication.
diff --git a/src/FlareSolverrSharp/ClearanceHandler.cs b/src/FlareSolverrSharp/ClearanceHandler.cs
index e166383..4db553b 100644
--- a/src/FlareSolverrSharp/ClearanceHandler.cs
+++ b/src/FlareSolverrSharp/ClearanceHandler.cs
@@ -34,6 +34,16 @@ public class ClearanceHandler : DelegatingHandler
///
public string ProxyUrl = "";
+ ///
+ /// HTTP Proxy Username.
+ ///
+ public string ProxyUsername = null;
+
+ ///
+ /// HTTP Proxy Password.
+ ///
+ public string ProxyPassword = null;
+
private HttpClientHandler HttpClientHandler => InnerHandler.GetMostInnerHandler() as HttpClientHandler;
///
@@ -73,7 +83,9 @@ protected override async Task SendAsync(HttpRequestMessage
_flareSolverr = new FlareSolverr(_flareSolverrApiUrl)
{
MaxTimeout = MaxTimeout,
- ProxyUrl = ProxyUrl
+ ProxyUrl = ProxyUrl,
+ ProxyUsername = ProxyUsername,
+ ProxyPassword = ProxyPassword
};
}
diff --git a/src/FlareSolverrSharp/Solvers/FlareSolverr.cs b/src/FlareSolverrSharp/Solvers/FlareSolverr.cs
index f4e6628..866c9e4 100644
--- a/src/FlareSolverrSharp/Solvers/FlareSolverr.cs
+++ b/src/FlareSolverrSharp/Solvers/FlareSolverr.cs
@@ -18,6 +18,8 @@ public class FlareSolverr
public int MaxTimeout = 60000;
public string ProxyUrl = "";
+ public string ProxyUsername = null;
+ public string ProxyPassword = null;
public FlareSolverr(string flareSolverrApiUrl)
{
@@ -152,7 +154,15 @@ private FlareSolverrRequestProxy GetProxy()
{
proxy = new FlareSolverrRequestProxy
{
- Url = ProxyUrl
+ Url = ProxyUrl,
+ };
+ if (!string.IsNullOrWhiteSpace(ProxyUsername)
+ {
+ proxy.Username = ProxyUsername;
+ };
+ if (!string.IsNullOrWhiteSpace(ProxyPassword))
+ {
+ proxy.Password = ProxyPassword;
};
}
return proxy;
@@ -172,7 +182,7 @@ private HttpContent GenerateFlareSolverrRequest(HttpRequestMessage request, stri
{
FlareSolverrRequest req;
if (string.IsNullOrWhiteSpace(sessionId))
- sessionId = null;
+ sessionId = null;
var url = request.RequestUri.ToString();
@@ -223,6 +233,6 @@ private HttpContent GenerateFlareSolverrRequest(HttpRequestMessage request, stri
return GetSolverRequestContent(req);
}
-
+
}
-}
\ No newline at end of file
+}
diff --git a/src/FlareSolverrSharp/Types/FlareSolverrRequestProxy.cs b/src/FlareSolverrSharp/Types/FlareSolverrRequestProxy.cs
index d8e3135..9186e09 100644
--- a/src/FlareSolverrSharp/Types/FlareSolverrRequestProxy.cs
+++ b/src/FlareSolverrSharp/Types/FlareSolverrRequestProxy.cs
@@ -6,5 +6,11 @@ public class FlareSolverrRequestProxy
{
[JsonProperty("url")]
public string Url;
+
+ [JsonProperty("username")]
+ public string Username;
+
+ [JsonProperty("password")]
+ public string Password;
}
}