perry-mitchell / webdav-client

WebDAV client written in Typescript for NodeJS and the browser
MIT License
661 stars 143 forks source link

ssl/tls support #337

Closed z1haze closed 1 year ago

z1haze commented 1 year ago

How to we explicitly set the port number? I do not see anywhere in the documentation on how to set the port to 443, for example

z1haze commented 1 year ago

Using an https host/url im seeing an error where it attempts to connect on port 80, which it should not.

Error: connect ECONNREFUSED ::1:80
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
[ERROR] 11:02:49 Error: connect ECONNREFUSED ::1:80
perry-mitchell commented 1 year ago

Have you tried just specifying it in the HTTP/S URL?

const client = createClient(
    "https://webdav.example.com:9000/test",
    {
        username: "test",
        password: "test"
    }
);

And 443 would be set automatically for the https protocol, so no need to manually specify that.

perry-mitchell commented 1 year ago

@z1haze Here you can see us taking in the remote URL and storing it in config. Here you can see us using that same URL for an action, without modification. Here we make a call to the underlying native fetch implementation, or node-fetch in Node, when making the request.

The protocol in the URL dictates the port unless you override it. https://... will inherently use 443, and http:// will inherently use 80. Specifying another port as I mentioned in the previous example will force the underlying request engine to try connecting on that port instead of 443/80.

I'm afraid there's no magic going on in this library with regards to ports. Closing for now as I don't think there's anything actionable here from our side.