httpx

package
v0.0.0-...-152b8de Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserAgentTransport

type UserAgentTransport struct {
	// Base is the base RoundTripper used to make HTTP requests.
	// If nil, http.DefaultTransport is used.
	Base http.RoundTripper

	// UserAgent is the value of the User-Agent header
	UserAgent string
}

UserAgentTransport wraps a given http.RoundTripper and sets a custom User-Agent header for all HTTP requests.

func NewUserAgentTransport

func NewUserAgentTransport(base http.RoundTripper, userAgent string) *UserAgentTransport

NewUserAgentTransport creates a new UserAgentTransport, which wraps a given http.RoundTripper and sets a custom User-Agent header for all HTTP requests.

func (*UserAgentTransport) RoundTrip

func (u *UserAgentTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and sets the User-Agent header.

Per the http.RoundTripper contract, it clones the provided request to ensure the original request is unmodified.

Jump to

Keyboard shortcuts

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