http

package module
v0.0.0-...-ca8f35e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client = internal.Client

Client provides the basic API for sending HTTP requests

Example
cl := &Client{}
resp, err := cl.CtxDo(context.Background(), &Request{
	Method: "GET",
	URL:    "http://www.google.com/?a=b",
	Header: http.Header{
		// "Connection": {"close"},
	},
})
if err != nil {
	fmt.Println(err)
	return
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
fmt.Println(err)
fmt.Println(string(b))
Output:

type CoreDialer

type CoreDialer = dialer.CoreDialer

CoreDialer is the default implementation of the Dialer interface. It would be used by a zero value Client.

type Dialer

type Dialer = http.Dialer

Dialers are responsible for creating underlying streams that http requests could be written to and responses could be read from. for example, opening a raw TCP connection for HTTP/1.1 requests.

Unlike net/http.Transport, A Dialer MUST NOT hold active connection states, which means a Dialer must be able to be swapped out from a Client without pain. Like net/http.Transport, it SHOULD hold the connection related configs like [ProxyConfiguration] or *net/tls.Config.

type Header = http.Header

type ProxyConfig

type ProxyConfig = dialer.ProxyConfig

type Request

type Request = http.Request

Requests are re-usable objects that are high-level representations of a HTTP request. A request would be "prepared" into *[PreparedRequest]s to be actually written into an underlying connection (i.e. a TCP stream)

type ResolveConfig

type ResolveConfig = dialer.ResolveConfig

we need a dedicated resolver for two scenarios:

  1. Resolve remote address locally in proxied requests
  2. to customize the DNS server used for resolving hostname

the standard library didn't provide a intuitive way of setting DNS server addresses since it only follows the system configuration (e.g. /etc/resolv.conf), leaving us only one option of using net.Resolver.Dial hook with a Go Resolver.

this part of code tries to take advantage of that only option as far as possible to provide a relativly intuitive configuration API.

type Response

type Response = http.Response

Responses are high-level representations of a HTTP response.

Directories

Path Synopsis
http
package http contains the request and response type, which are meant to be exported.
package http contains the request and response type, which are meant to be exported.
utils

Jump to

Keyboard shortcuts

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