Documentation
¶
Overview ¶
Package web is the one way celestial-data reaches an archive: a GET, a HEAD and a POST. A client keeps the cookies its answers set, so a session signed in goes with what it asks. Everything goes through Web, so a test can hold an adapter to the exact addresses it asks for.
Index ¶
- func Seconds(count float64) time.Duration
- type Client
- func (client Client) Cookies(address string) ([]*http.Cookie, error)
- func (client Client) Get(url string) (io.ReadCloser, int64, error)
- func (client Client) Head(url string) (int64, error)
- func (client Client) Keep(address string, cookies []*http.Cookie) error
- func (client Client) Post(address string, form url.Values) (string, error)
- type Status
- type Web
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is Web over HTTP. Its zero value is not ready; New makes one.
func New ¶
New makes a Client. The server gets wait to connect and to begin its answer. The whole request gets whole, up to its last byte. Zero is no limit. That suits a large file on a slow link.
func Patient ¶ added in v0.0.3
Patient makes a Client whose server gets wait to connect and to begin its answer, and whose whole request has no limit, so a large file on a slow link is never cut off.
func (Client) Cookies ¶
Cookies are the cookies the client holds for an address: those its answers set, and those Keep gave it.
func (Client) Get ¶
Get is Web's Get over HTTP. Any answer but a success is an error that names the URL and the status. Its body is closed.
type Status ¶ added in v0.0.2
type Status struct {
// contains filtered or unexported fields
}
Status is an answer that was not a success, as Get and Head refuse it: the request's method and address, the status as the server wrote it and its code, and its Retry-After header as written, or none. A caller that must stop when a server asks it to wait reads Code.
func (*Status) RetryAfter ¶ added in v0.0.2
RetryAfter is how long the server asked us to wait, as its Retry-After header wrote it: seconds or a date. It is empty when it asked none.
type Web ¶
type Web interface {
// Get opens what a URL holds. length is the number of bytes the
// server said it would send, or -1 when it did not say.
Get(url string) (body io.ReadCloser, length int64, err error)
// Head is the length of what a URL holds, as its server tells it.
// It is -1 when the server does not say.
Head(url string) (length int64, err error)
// Post sends a form to an address and gives the address its answer
// sends on to, or none. It does not go on to it.
Post(address string, form url.Values) (where string, err error)
}
Web is what an adapter asks of the network.