miniflux.appminiflux.app/http/client Index | Files

package client

import "miniflux.app/http/client"

Index

Types

type Client

type Client struct {
	ClientTimeout               int
	ClientMaxBodySize           int64
	ClientProxyURL              string
	AllowSelfSignedCertificates bool
	// contains filtered or unexported fields
}

Client builds and executes HTTP requests.

func New

func New(url string) *Client

New initializes a new HTTP client.

func NewClientWithConfig

func NewClientWithConfig(url string, opts *config.Options) *Client

NewClientWithConfig initializes a new HTTP client with application config options.

func (*Client) Get

func (c *Client) Get() (*Response, error)

Get performs a GET HTTP request.

func (*Client) PatchJSON

func (c *Client) PatchJSON(data interface{}) (*Response, error)

PatchJSON performs a Patch HTTP request with a JSON payload.

func (*Client) PostForm

func (c *Client) PostForm(values url.Values) (*Response, error)

PostForm performs a POST HTTP request with form encoded values.

func (*Client) PostJSON

func (c *Client) PostJSON(data interface{}) (*Response, error)

PostJSON performs a POST HTTP request with a JSON payload.

func (*Client) String

func (c *Client) String() string

func (*Client) WithAuthorization

func (c *Client) WithAuthorization(authorization string) *Client

WithAuthorization defines the authorization HTTP header value.

func (*Client) WithCacheHeaders

func (c *Client) WithCacheHeaders(etagHeader, lastModifiedHeader string) *Client

WithCacheHeaders defines caching headers.

func (*Client) WithCookie

func (c *Client) WithCookie(cookie string) *Client

WithCookie defines the Cookies to use for HTTP requests.

func (*Client) WithCredentials

func (c *Client) WithCredentials(username, password string) *Client

WithCredentials defines the username/password for HTTP Basic authentication.

func (*Client) WithCustomHeaders

func (c *Client) WithCustomHeaders(customHeaders map[string]string) *Client

WithCustomHeaders defines custom HTTP headers.

func (*Client) WithProxy

func (c *Client) WithProxy() *Client

WithProxy enables proxy for the current HTTP request.

func (*Client) WithUserAgent

func (c *Client) WithUserAgent(userAgent string) *Client

WithUserAgent defines the User-Agent header to use for HTTP requests.

func (*Client) WithoutRedirects

func (c *Client) WithoutRedirects() *Client

WithoutRedirects disables HTTP redirects.

type Response

type Response struct {
	Body          io.Reader
	StatusCode    int
	EffectiveURL  string
	LastModified  string
	ETag          string
	Expires       string
	ContentType   string
	ContentLength int64
}

Response wraps a server response.

func (*Response) BodyAsString

func (r *Response) BodyAsString() string

BodyAsString returns the response body as string.

func (*Response) EnsureUnicodeBody

func (r *Response) EnsureUnicodeBody() (err error)

EnsureUnicodeBody makes sure the body is encoded in UTF-8.

If a charset other than UTF-8 is detected, we convert the document to UTF-8. This is used by the scraper and feed readers.

Do not forget edge cases:

- Feeds with encoding specified only in Content-Type header and not in XML document - Feeds with encoding specified in both places - Feeds with encoding specified only in XML document and not in HTTP header - Feeds with wrong encoding defined and already in UTF-8

func (*Response) HasServerFailure

func (r *Response) HasServerFailure() bool

HasServerFailure returns true if the status code represents a failure.

func (*Response) IsModified

func (r *Response) IsModified(etag, lastModified string) bool

IsModified returns true if the resource has been modified.

func (*Response) IsNotAuthorized

func (r *Response) IsNotAuthorized() bool

IsNotAuthorized returns true if the resource require authentication.

func (*Response) IsNotFound

func (r *Response) IsNotFound() bool

IsNotFound returns true if the resource doesn't exist anymore.

func (*Response) String

func (r *Response) String() string

Source Files

client.go response.go

Version
v1.0.46 (latest)
Published
Jul 22, 2023
Platform
linux/amd64
Imports
18 packages
Last checked
2 weeks ago

Tools for package owners.