Introduce HTTPClient, remove Client.SetBasicAuth

This commit is contained in:
Simon Ser
2020-02-19 16:02:49 +01:00
parent c52097fefb
commit ddf2a85958
4 changed files with 37 additions and 31 deletions

View File

@@ -3,7 +3,6 @@ package caldav
import (
"bytes"
"fmt"
"net/http"
"time"
"github.com/emersion/go-webdav"
@@ -18,7 +17,7 @@ type Client struct {
ic *internal.Client
}
func NewClient(c *http.Client, endpoint string) (*Client, error) {
func NewClient(c webdav.HTTPClient, endpoint string) (*Client, error) {
wc, err := webdav.NewClient(c, endpoint)
if err != nil {
return nil, err
@@ -30,11 +29,6 @@ func NewClient(c *http.Client, endpoint string) (*Client, error) {
return &Client{wc, ic}, nil
}
func (c *Client) SetBasicAuth(username, password string) {
c.Client.SetBasicAuth(username, password)
c.ic.SetBasicAuth(username, password)
}
func (c *Client) FindCalendarHomeSet(principal string) (string, error) {
propfind := internal.NewPropNamePropfind(calendarHomeSetName)
resp, err := c.ic.PropfindFlat(principal, propfind)