Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct { // URL is the HTTPs endpoint. URL string // Method is the HTTP method to use in the request. Method string // TrustedCertFingerprint is the sha256 hash of a server's trusted // (self-signed) TLS certificate. TrustedCertFingerprint []byte }
Request encapsulates an HTTPs request.
type Response ¶
type Response struct { // Data is the received request payload. Data []byte // HTTPStatusCode is the HTTP status code of the response. HTTPStatusCode int // RedirectURL is the Location header of a HTTP redirect response. RedirectURL string }
Response encapsulates an HTTPs response.
func Fetch ¶
Fetch retrieves data from an HTTPs server that may have a self-singed TLS certificate. Pins the trusted certificate when req.TrustedCertFingerprint is non-empty. Follows up to 10 HTTPs redirects and sets the response's RedirectURL to the last Location header URL when the status code is a permantent redirect. Returns an error if req.URL is a non-HTTPS URL, if there is a connection error to the server, or if reading the response fails.
Click to show internal directories.
Click to hide internal directories.