web

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Seconds

func Seconds(count float64) time.Duration

Seconds is a count of seconds as a wait New takes. The waits celestial-data picks are kept in numbers files as seconds.

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

func New(wait, whole time.Duration, agent string) Client

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 (Client) Cookies

func (client Client) Cookies(address string) ([]*http.Cookie, error)

Cookies are the cookies the client holds for an address: those its answers set, and those Keep gave it.

func (Client) Get

func (client Client) Get(url string) (io.ReadCloser, int64, error)

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.

func (Client) Head

func (client Client) Head(url string) (int64, error)

Head is Web's Head over HTTP.

func (Client) Keep

func (client Client) Keep(address string, cookies []*http.Cookie) error

Keep gives the client cookies to send to an address, as a session signed in before would be.

func (Client) Post

func (client Client) Post(address string, form url.Values) (string,
	error)

Post is Web's Post over HTTP. An answer that is neither a success nor a redirect is an error that names the address and the status, and never the form, which may hold a password.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL