Add proxy from launch argument to WebApi

Co-authored-by: Nekromateion <43814053+Nekromateion@users.noreply.github.com>
This commit is contained in:
Natsumi
2024-07-17 06:42:33 +12:00
parent 8740905a08
commit a4d03c7e00
5 changed files with 21 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ namespace VRCX
public CookieContainer _cookieContainer;
private bool _cookieDirty;
private Timer _timer;
public static IWebProxy? Proxy = WebRequest.DefaultWebProxy;
static WebApi()
{
@@ -144,7 +145,7 @@ namespace VRCX
private static async Task LegacyImageUpload(HttpWebRequest request, IDictionary<string, object> options)
{
request.Proxy = StartupArgs.Proxy;
request.Proxy = Proxy;
request.Method = "POST";
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
request.ContentType = "multipart/form-data; boundary=" + boundary;
@@ -189,7 +190,7 @@ namespace VRCX
private static async Task UploadFilePut(HttpWebRequest request, IDictionary<string, object> options)
{
request.Proxy = StartupArgs.Proxy;
request.Proxy = Proxy;
request.Method = "PUT";
request.ContentType = options["fileMIME"] as string;
var fileData = options["fileData"] as string;
@@ -204,7 +205,7 @@ namespace VRCX
private static async Task ImageUpload(HttpWebRequest request, IDictionary<string, object> options)
{
request.Proxy = StartupArgs.Proxy;
request.Proxy = Proxy;
request.Method = "POST";
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
request.ContentType = "multipart/form-data; boundary=" + boundary;
@@ -258,7 +259,7 @@ namespace VRCX
try
{
var request = WebRequest.CreateHttp((string)options["url"]);
request.Proxy = StartupArgs.Proxy;
request.Proxy = Proxy;
request.CookieContainer = _cookieContainer;
request.KeepAlive = true;
request.UserAgent = Program.Version;