http

package
v0.0.0-...-bed8137 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultShutdownTimeout - default shutdown timeout used for graceful http server shutdown.
	DefaultShutdownTimeout = 5 * time.Second

	// DefaultTCPKeepAliveTimeout - default TCP keep alive timeout for accepted connection.
	DefaultTCPKeepAliveTimeout = 10 * time.Second

	// DefaultReadTimeout - default timout to read data from accepted connection.
	DefaultReadTimeout = 5 * time.Minute

	// DefaultWriteTimeout - default timout to write data to accepted connection.
	DefaultWriteTimeout = 5 * time.Minute

	// DefaultMaxHeaderBytes - default maximum HTTP header size in bytes.
	DefaultMaxHeaderBytes = 1 * humanize.MiByte
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BufConn

type BufConn struct {
	QuirkConn
	// contains filtered or unexported fields
}

BufConn - is a generic stream-oriented network connection supporting buffered reader and read/write timeout.

func (*BufConn) Peek

func (c *BufConn) Peek(n int) ([]byte, error)

Peek - returns the next n bytes without advancing the reader. It just wraps bufio.Reader.Peek().

func (*BufConn) Read

func (c *BufConn) Read(b []byte) (n int, err error)

Read - reads data from the connection using wrapped buffered reader.

func (*BufConn) RemoveTimeout

func (c *BufConn) RemoveTimeout()

RemoveTimeout - removes all configured read and write timeouts. Used by callers which control net.Conn behavior themselves.

func (*BufConn) Write

func (c *BufConn) Write(b []byte) (n int, err error)

Write - writes data to the connection.

type QuirkConn

type QuirkConn struct {
	net.Conn
	// contains filtered or unexported fields
}

QuirkConn - similar to golang net.Conn struct, but contains a workaround of the following the go bug reported here https://github.com/golang/go/issues/21133. Once the bug will be fixed, we can remove this structure and replaces it with the standard net.Conn

func (*QuirkConn) SetReadDeadline

func (q *QuirkConn) SetReadDeadline(t time.Time) error

SetReadDeadline - implements a workaround of SetReadDeadline go bug

type Server

type Server struct {
	http.Server
	Addrs                  []string      // addresses on which the server listens for new connection.
	ShutdownTimeout        time.Duration // timeout used for graceful server shutdown.
	TCPKeepAliveTimeout    time.Duration // timeout used for underneath TCP connection.
	UpdateBytesReadFunc    func(int)     // function to be called to update bytes read in bufConn.
	UpdateBytesWrittenFunc func(int)     // function to be called to update bytes written in bufConn.
	// contains filtered or unexported fields
}

Server - extended http.Server supports multiple addresses to serve and enhanced connection handling.

func NewServer

func NewServer(addrs []string, handler http.Handler, certificate *tls.Certificate) *Server

NewServer - creates new HTTP server using given arguments.

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shutdown - shuts down HTTP server.

func (*Server) Start

func (srv *Server) Start() (err error)

Start - start HTTP server

Jump to

Keyboard shortcuts

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