1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add per feed cookies option

This commit is contained in:
Darius 2021-03-23 04:27:58 +01:00 committed by GitHub
parent b0c14aa8f9
commit 9242350f0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 114 additions and 15 deletions

View file

@ -47,6 +47,7 @@ type Client struct {
requestUsername string
requestPassword string
requestUserAgent string
requestCookie string
useProxy bool
doNotFollowRedirects bool
@ -142,6 +143,14 @@ func (c *Client) WithUserAgent(userAgent string) *Client {
return c
}
// WithCookie defines the Cookies to use for HTTP requests.
func (c *Client) WithCookie(cookie string) *Client {
if cookie != "" {
c.requestCookie = cookie
}
return c
}
// Get performs a GET HTTP request.
func (c *Client) Get() (*Response, error) {
request, err := c.buildRequest(http.MethodGet, nil)
@ -336,6 +345,10 @@ func (c *Client) buildHeaders() http.Header {
headers.Add("Authorization", c.requestAuthorizationHeader)
}
if c.requestCookie != "" {
headers.Add("Cookie", c.requestCookie)
}
headers.Add("Connection", "close")
return headers
}