http

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 2 Imported by: 13

Documentation

Index

Constants

View Source
const (
	Continue Code = 100
	OK            = 200

	Created                     = 201
	Accepted                    = 202
	NonAuthoritativeInformation = 203
	NoContent                   = 204
	ResetContent                = 205
	PartialContent              = 206
	MultiStatus                 = 207
	AlreadyReported             = 208
	IMUsed                      = 226

	MultipleChoices   = 300
	MovedPermanently  = 301
	Found             = 302
	SeeOther          = 303
	NotModified       = 304
	UseProxy          = 305
	TemporaryRedirect = 307
	PermanentRedirect = 308

	BadRequest                  = 400
	Unauthorized                = 401
	PaymentRequired             = 402
	Forbidden                   = 403
	NotFound                    = 404
	MethodNotAllowed            = 405
	NotAcceptable               = 406
	ProxyAuthenticationRequired = 407
	RequestTimeout              = 408
	Conflict                    = 409
	Gone                        = 410
	LengthRequired              = 411
	PreconditionFailed          = 412
	PayloadTooLarge             = 413
	URITooLong                  = 414
	UnsupportedMediaType        = 415
	RangeNotSatisfiable         = 416
	ExpectationFailed           = 417
	MisdirectedRequest          = 421
	UnprocessableEntity         = 422
	Locked                      = 423
	FailedDependency            = 424
	UpgradeRequired             = 426
	PreconditionRequired        = 428
	TooManyRequests             = 429
	RequestHeaderFieldsTooLarge = 431

	InternalServerError           = 500
	NotImplemented                = 501
	BadGateway                    = 502
	ServiceUnavailable            = 503
	GatewayTimeout                = 504
	HTTPVersionNotSupported       = 505
	VariantAlsoNegotiates         = 506
	InsufficientStorage           = 507
	LoopDetected                  = 508
	NotExtended                   = 510
	NetworkAuthenticationRequired = 511

	PlaceHolder = "-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code uint32

type RequestHeader

type RequestHeader struct {
	*fasthttp.RequestHeader
}

func (RequestHeader) Add

func (h RequestHeader) Add(key, value string)

Add value for given key. Multiple headers with the same key may be added with this function. Use Set for setting a single header for the given key.

func (RequestHeader) ByteSize

func (h RequestHeader) ByteSize() (size uint64)

func (RequestHeader) Clone

func (h RequestHeader) Clone() api.HeaderMap

func (RequestHeader) Del

func (h RequestHeader) Del(key string)

Del delete pair of specified key

func (RequestHeader) Get

func (h RequestHeader) Get(key string) (string, bool)

Get value of key

func (RequestHeader) Range

func (h RequestHeader) Range(f func(key, value string) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (RequestHeader) Set

func (h RequestHeader) Set(key string, value string)

Set key-value pair in header map, the previous pair will be replaced if exists

Due to the fact that fasthttp's implementation doesn't have correct semantic for Set("key", "") and Peek("key") at the first time of usage. We need another way for compensate.

The problem is caused by the func initHeaderKV, if the original kv.value is nil, ant input value is also nil, then the final kv.value remains nil.

kv.value = append(kv.value[:0], value...)

fasthttp do has the kv entry, but kv.value is nil, so Peek("key") return nil. But we want "" instead.

type ResponseHeader

type ResponseHeader struct {
	*fasthttp.ResponseHeader
}

func (ResponseHeader) Add

func (h ResponseHeader) Add(key, value string)

Add value for given key. Multiple headers with the same key may be added with this function. Use Set for setting a single header for the given key.

func (ResponseHeader) ByteSize

func (h ResponseHeader) ByteSize() (size uint64)

func (ResponseHeader) Clone

func (h ResponseHeader) Clone() api.HeaderMap

func (ResponseHeader) Del

func (h ResponseHeader) Del(key string)

Del delete pair of specified key

func (ResponseHeader) Get

func (h ResponseHeader) Get(key string) (string, bool)

Get value of key

func (ResponseHeader) Range

func (h ResponseHeader) Range(f func(key, value string) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (ResponseHeader) Set

func (h ResponseHeader) Set(key string, value string)

Set key-value pair in header map, the previous pair will be replaced if exists

Due to the fact that fasthttp's implementation doesn't have correct semantic for Set("key", "") and Peek("key") at the first time of usage. We need another way for compensate.

The problem is caused by the func initHeaderKV, if the original kv.value is nil, ant input value is also nil, then the final kv.value remains nil.

kv.value = append(kv.value[:0], value...)

fasthttp do has the kv entry, but kv.value is nil, so Peek("key") return nil. But we want "" instead.

Jump to

Keyboard shortcuts

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