http

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

http.go - simple http client to aid in timing measurements

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkedStreamReader

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

ChunkedStreamReader offers a streaming reader interface that accommodates arbitrary caller read sizes.

func NewChunkedStreamReader

func NewChunkedStreamReader(rd *connCloser) *ChunkedStreamReader

func (*ChunkedStreamReader) Close

func (c *ChunkedStreamReader) Close() error

func (*ChunkedStreamReader) Read

func (c *ChunkedStreamReader) Read(p []byte) (int, error)

type Client

type Client struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

Client to handle connections and requests

func NewClient

func NewClient(timeout time.Duration) *Client

NewClient creates a new HTTP client with a specified timeout

func (*Client) Do

func (c *Client) Do(req *Request, ctx context.Context) (*Response, error)

Do sends an HTTP request and returns the response as a string

type Header = nh.Header

type Request

type Request struct {
	Method  string
	URL     string
	Host    string
	Headers Header
}

Request structure to hold HTTP method, headers, and body

func NewRequest

func NewRequest(meth, url string) *Request

type Response

type Response struct {
	Req *Request

	Proto      string
	Status     string
	StatusCode int

	ContentLength int64

	Headers Header

	Body io.ReadCloser

	// various timings
	Dns  time.Duration
	Tcp  time.Duration
	Tls  time.Duration
	Http time.Duration
	E2e  time.Duration
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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