skazantsev / WebDavClient

Asynchronous cross-platform WebDAV client for .NET Core
MIT License
158 stars 30 forks source link

WebDAV access behind a proxy #50

Open juapepa opened 4 years ago

juapepa commented 4 years ago

We want to upload WebDAV files using this .NET API. However, in order to connect to our WebDAV server, we are required to use a proxy (with authentication). Could this library work behind a proxy?

Thank you in advance

skazantsev commented 4 years ago

Hi @juapepa ,

There a few ways to set up a proxy when instantiating WebDavClient:

  1. You can pass an WebProxy to WebDevClientParams.
  2. You can pass a pre-configured instance of HttpClient to WebDavClient.

here is a code example:

var clientParams = new WebDavClientParams
{
    BaseAddress = new Uri("..."),
    UseProxy = true,
    Proxy = new WebProxy(...)
};
using var client = new WebDavClient(clientParams);
ngost commented 11 months ago

When using Socks5 proxy, WebProxy Class not work on .Net 4.x, 5.x ..

Can create proxy class for socks5 using like HttpToSocks5Proxy.1.4.0 in nuget pakages.

example, HttpToSocks5Proxy httpToSocks5Proxy = new HttpToSocks5Proxy("127.0.0.1", xxxx); proxy = httpToSocks5Proxy;

and, HttpToSocks5Proxy class is implement IWebProxy Class.

Useful under .Net 6 framework like unity platform.