core

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package core handles the core functionality of requests apart from any convenience functions and patterns.

Index

Constants

This section is empty.

Variables

View Source
var PathCases = map[string]struct {
	Base   string
	Paths  []string
	Result string
}{
	"base-only": {
		"example",
		[]string{},
		"https://example",
	},
	"base+abspath": {
		"https://example",
		[]string{"/a"},
		"https://example/a",
	},
	"multi-abs-paths": {
		"https://example",
		[]string{"/a", "/b/", "/c"},
		"https://example/c",
	},
	"base+rel-path": {
		"https://example/a/",
		[]string{"./b"},
		"https://example/a/b",
	},
	"base+rel-paths": {
		"https://example/a/",
		[]string{"./b/", "./c"},
		"https://example/a/b/c",
	},
	"rel-path": {
		"https://example/",
		[]string{"a/", "./b"},
		"https://example/a/b",
	},
	"base+multi-paths": {
		"https://example/a/",
		[]string{"b/", "c"},
		"https://example/a/b/c",
	},
	"base+slash+multi-paths": {
		"https://example/a/",
		[]string{"b/", "c"},
		"https://example/a/b/c",
	},
	"multi-root": {
		"https://example/",
		[]string{"a", "b", "c"},
		"https://example/c",
	},
	"dot-dot-paths": {
		"https://example/",
		[]string{"a/", "b/", "../c"},
		"https://example/a/c",
	},
	"more-dot-dot-paths": {
		"https://example/",
		[]string{"a/b/c/", "../d/", "../e"},
		"https://example/a/b/e",
	},
	"more-dot-dot-paths+rel-path": {
		"https://example/",
		[]string{"a/b/c/", "../d/", "../e/", "./f"},
		"https://example/a/b/e/f",
	},
	"even-more-dot-dot-paths+base": {
		"https://example/a/b/c/",
		[]string{"../../d"},
		"https://example/a/d",
	},
	"too-many-dot-dot-paths": {
		"https://example",
		[]string{"../a"},
		"https://example/a",
	},
	"too-many-dot-dot-paths+base": {
		"https://example/",
		[]string{"../a"},
		"https://example/a",
	},
	"last-abs-path-wins": {
		"https://example/a/",
		[]string{"b/", "c/", "/d"},
		"https://example/d",
	},
}

PathCases is exported to share tests with requests

Functions

This section is empty.

Types

type BodyGetter

type BodyGetter = func() (io.ReadCloser, error)

type NopCloser

type NopCloser struct {
	io.Reader
}

NopCloser is like io.NopCloser(), but it is a concrete type so we can strip it out before setting a body on a request. See https://github.com/carlmjohnson/requests/discussions/49

func RC

func RC(r io.Reader) NopCloser

func (NopCloser) Close

func (NopCloser) Close() error

type RequestBuilder

type RequestBuilder struct {
	// contains filtered or unexported fields
}

func (*RequestBuilder) Body

func (rb *RequestBuilder) Body(src BodyGetter)

func (*RequestBuilder) Clone

func (rb *RequestBuilder) Clone() *RequestBuilder

Clone creates a new Builder suitable for independent mutation.

func (*RequestBuilder) Cookie

func (rb *RequestBuilder) Cookie(name, value string)

func (*RequestBuilder) Header

func (rb *RequestBuilder) Header(key string, values ...string)

func (*RequestBuilder) Method

func (rb *RequestBuilder) Method(method string)

func (*RequestBuilder) Request

func (rb *RequestBuilder) Request(ctx context.Context, u *url.URL) (req *http.Request, err error)

Request builds a new http.Request with its context set.

type URLBuilder

type URLBuilder struct {
	// contains filtered or unexported fields
}

func (*URLBuilder) BaseURL

func (ub *URLBuilder) BaseURL(baseurl string)

func (*URLBuilder) Clone

func (ub *URLBuilder) Clone() *URLBuilder

func (*URLBuilder) Host

func (ub *URLBuilder) Host(host string)

func (*URLBuilder) Param

func (ub *URLBuilder) Param(key string, values ...string)

func (*URLBuilder) Path

func (ub *URLBuilder) Path(path string)

func (*URLBuilder) Scheme

func (ub *URLBuilder) Scheme(scheme string)

func (*URLBuilder) URL

func (ub *URLBuilder) URL() (u *url.URL, err error)

Jump to

Keyboard shortcuts

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