http

package
v0.0.0-...-4ef28c0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionKindEnd    = 0 // End of option list
	OptionKindNOP    = 1
	OptionKindMSS    = 2
	OptionKindWScale = 3
)
View Source
const MaxSeqNum = 1<<32 - 1

Variables

This section is empty.

Functions

func LookupLocalIP

func LookupLocalIP() (net.IP, error)

Find my local IPv4 address

func LookupRemoteIP

func LookupRemoteIP(hostname string) (net.IP, error)

Find the IPv4 address of a remote host

Types

type Client

type Client struct {
	Timeout time.Duration
}

This Client does not maintain a persistent connection

func NewClient

func NewClient() *Client

func (*Client) Do

func (c *Client) Do(req *Request) (*Response, error)

Do the Request and return the Response. The ephemeral connection lives in here.

func (*Client) Get

func (c *Client) Get(url string) (*Response, error)

Make a Get request for the given url string

type Conn

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

Conn is a custom network connection that uses raw sockets

func NewConn

func NewConn(hostname string, timeout time.Duration) (*Conn, error)

NewConn Make a new Conn struct that holds stateful information.

func (*Conn) Close

func (c *Conn) Close() error

Close the underlying file descriptors.

func (*Conn) RecvResponse

func (c *Conn) RecvResponse() (io.Reader, error)

RecvResponse receives all data from the GET request and returns a reader as a stream

func (*Conn) SendRequest

func (c *Conn) SendRequest(req *Request) error

SendRequest sends the request to the remote host.

type LinkedList

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

func NewLinkedList

func NewLinkedList() *LinkedList

func (*LinkedList) InsertNode

func (ll *LinkedList) InsertNode(newNode *Node)

InsertNode inserts a new Node in the linked list in the correct order based on sequence number.

func (*LinkedList) ToBytes

func (ll *LinkedList) ToBytes() []byte

type LinkedListReader

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

LinkedListReader implements Reader interface for streaming

func NewLinkedListReader

func NewLinkedListReader(list *LinkedList) *LinkedListReader

func (*LinkedListReader) Read

func (r *LinkedListReader) Read(buf []byte) (n int, err error)

type Node

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

type Request

type Request struct {
	Method  string
	Url     *url.URL
	Proto   string // HTTP/1.0
	Headers map[string]string
	Body    []byte // Not used since we only support GET request
}

func (*Request) ToBytes

func (r *Request) ToBytes() []byte

ToBytes converts the Request into a byte array. It will sort the headers in alphabetical order.

type Response

type Response struct {
	Url        *url.URL
	StatusCode int
	Reason     string
	Headers    map[string]string
	Body       io.ReadCloser // Mimic the Go std lib
}

func ParseResponse

func ParseResponse(url *url.URL, reader io.Reader) (*Response, error)

ParseResponse parses the raw response into a Response object

type TCPOptions

type TCPOptions func(options *[]byte)

func WithMSS

func WithMSS(mss uint16) TCPOptions

func WithWScale

func WithWScale(wscale uint8) TCPOptions

Jump to

Keyboard shortcuts

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