Simplify request creation when getting capabilities.

This commit is contained in:
Joachim Bauch 2021-07-07 12:28:45 +02:00
parent dc713ea8e8
commit 66bcf2468d
No known key found for this signature in database
GPG Key ID: 77C1D22D53E15F02
1 changed files with 5 additions and 9 deletions

View File

@ -210,20 +210,16 @@ func (b *BackendClient) getCapabilities(ctx context.Context, u *url.URL) (map[st
}
defer pool.Put(c)
req := &http.Request{
Method: "GET",
URL: &capUrl,
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
Header: make(http.Header),
Host: u.Host,
req, err := http.NewRequestWithContext(ctx, "GET", capUrl.String(), nil)
if err != nil {
log.Printf("Could not create request to %s: %s", &capUrl, err)
return nil, err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("OCS-APIRequest", "true")
req.Header.Set("User-Agent", "nextcloud-spreed-signaling/"+b.version)
resp, err := c.Do(req.WithContext(ctx))
resp, err := c.Do(req)
if err != nil {
return nil, err
}