studio-b12 / gowebdav

A golang WebDAV client library and command line tool.
BSD 3-Clause "New" or "Revised" License
309 stars 89 forks source link

Support for cookies #64

Closed ueffel closed 1 year ago

ueffel commented 1 year ago

Hello Collaborators,

can we add the ability to set the CookieJar of the internal http.Client of the gowebdav.Client? I got proprietary webdav server, which does authentication via kerberos. It is way faster to use the cookie after the initial authentication than to reauthenticate at every request.

I see 3 possibilities to implement this:

  1. provide a SetJar method for the gowebdav.Client like this

    func (c *Client) SetJar(jar http.CookieJar) {
    c.c.Jar = jar
    }
  2. expose the internal http.Client by making the c field public or add an option to gowebdav.NewClient so a configured http.Client for the webdav client to use can be provided.

  3. use the http.DefaultClient in gowebdav.NewClient function to initialize the c field.

I like number 2. with an option to provide a http.Client best, because it adds the most flexibility. Maybe there is a good reason why the library uses its own clean http.Client that I don't see right now. In that case I would like number 1 implemented.

Thoughts?

(I can provide the pull request if we reach a decision)

chripo commented 1 year ago

Hello @ueffel

Thank you for your request!

Yes, option 2 offers the most flexibility but also ties our lib up. Same for option 3.

Any thoughts left?

Pull request welcome!

ueffel commented 1 year ago

No other thoughts. I pull requested option 1.

chripo commented 1 year ago

Awesome!