fetch

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_HEADER_COUNT = 10000

When iterating headers, have a max header count, to prevent overflow if client code continuously add new headers while iterating.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body interface {
	io.Reader
	Body() streams.ReadableStream
}

Body represents the Body IDL mixin defined in the fetch API.

type Fetch

type Fetch struct {
	BrowsingContext html.BrowsingContext
}

func New

func New(bc html.BrowsingContext) Fetch

func (Fetch) Fetch

func (f Fetch) Fetch(req Request) (*Response, error)

func (Fetch) FetchAsync

func (f Fetch) FetchAsync(req Request) promise.Promise[*Response]

func (Fetch) NewRequest

func (f Fetch) NewRequest(url string, opts ...RequestOption) Request
type Header struct {
	// contains filtered or unexported fields
}

type Headers added in v0.9.2

type Headers struct {
	entity.Entity
	// contains filtered or unexported fields
}

func (*Headers) All added in v0.10.3

All() returns an iterator of key/value pairs of header keys and values. The same key may appear multiple times in the output. The returned order is guaranteed to be sorted by name. The iterator operates on a live list, i.e. new headers can be inserted while iterating. Panics if the number of headers iterated exceed MAX_HEADER_COUNT.

func (*Headers) Append added in v0.9.2

func (h *Headers) Append(name, val types.ByteString)

func (*Headers) Delete added in v0.9.2

func (h *Headers) Delete(name types.ByteString)

func (*Headers) Get added in v0.9.2

func (h *Headers) Get(name types.ByteString) (string, bool)

func (*Headers) Has added in v0.9.2

func (h *Headers) Has(name types.ByteString) bool

func (*Headers) Set added in v0.9.2

func (h *Headers) Set(name, value types.ByteString)

type ReadableStream

type ReadableStream struct {
	Reader io.Reader
}

func (ReadableStream) GetReader

func (s ReadableStream) GetReader(opts ...streams.GetReaderOption) streams.Reader

type Reader

type Reader struct {
	Reader io.Reader
	Done   bool
}

func (*Reader) Read

type Request

type Request struct {
	Headers Headers
	// contains filtered or unexported fields
}

func (*Request) URL

func (r *Request) URL() string

type RequestOption

type RequestOption func(*Request)

func WithBody added in v0.9.2

func WithBody(b io.Reader) RequestOption

func WithHeaders added in v0.10.3

func WithHeaders(h [][2]types.ByteString) RequestOption

func WithMethod added in v0.9.2

func WithMethod(m string) RequestOption

func WithSignal

func WithSignal(s *dom.AbortSignal) RequestOption

type Response

type Response struct {
	io.Reader
	Status  int
	Headers Headers
	// contains filtered or unexported fields
}

func (Response) Body

func (r Response) Body() streams.ReadableStream

Jump to

Keyboard shortcuts

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