feat: proxy creds
This commit is contained in:
@@ -20,13 +20,13 @@ namespace CarManagerV3.Forms
|
||||
|
||||
public NetworkCredential GetCredentails()
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Username: {tbxUsername.Text}, Password: {tbxPassword.Text}");
|
||||
return new NetworkCredential(tbxUsername.Text, tbxPassword.Text);
|
||||
}
|
||||
|
||||
private void NetCredentials_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.BringToFront();
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
private void btnAccept_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -99,13 +99,12 @@ namespace CarManagerV3
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
client.Headers.Add("Referer", "http://localhost");
|
||||
if (myNetCred != null)
|
||||
{
|
||||
client.Proxy.Credentials = myNetCred;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (myNetCred == null) throw new WebException();
|
||||
client.Credentials = myNetCred;
|
||||
client.Proxy.Credentials = myNetCred;
|
||||
//DEBUG:: if (myNetCred == null) throw new WebException();
|
||||
client.DownloadFile(url, path);
|
||||
}
|
||||
catch (WebException ex)
|
||||
@@ -127,11 +126,12 @@ namespace CarManagerV3
|
||||
}
|
||||
NetCredentials netCredForm = new NetCredentials();
|
||||
DialogResult dialogRes = netCredForm.ShowDialog();
|
||||
netCredForm.BringToFront();
|
||||
netCredForm.Focus();
|
||||
if (dialogRes == DialogResult.OK)
|
||||
{
|
||||
NetworkCredential netcred = netCredForm.GetCredentails();
|
||||
myNetCred = netcred;
|
||||
System.Diagnostics.Debug.WriteLine($"Got credentials: {netcred.UserName}, {netcred.Password}");
|
||||
FetchImage(car);
|
||||
return;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user