proxy

package
v0.0.0-...-a8801f6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2013 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VcapTraceHeader = "X-Vcap-Trace"

	VcapCookieId    = "__VCAP_ID__"
	StickyCookieKey = "JSESSIONID"
)
View Source
const (
	VcapBackendHeader     = "X-Vcap-Backend"
	CfRouteEndpointHeader = "X-Cf-RouteEndpoint"
	VcapRouterHeader      = "X-Vcap-Router"
)
View Source
const DefaultMaxHeaderBytes = 1 << 20 // 1 MB

DefaultMaxHeaderBytes is the maximum permitted size of the headers in an HTTP request. This can be overridden by setting Server.MaxHeaderBytes.

View Source
const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

TimeFormat is the time format to use with time.Parse and time.Time.Format when parsing or generating times in HTTP headers. It is like time.RFC1123 but hard codes GMT as the time zone.

Variables

View Source
var (
	ErrWriteAfterFlush = errors.New("Conn.Write called after Flush")
	ErrBodyNotAllowed  = errors.New("http: request method or response status code does not allow body")
	ErrHijacked        = errors.New("Conn has been hijacked")
	ErrContentLength   = errors.New("Conn.Write wrote more than the declared Content-Length")
)

Errors introduced by the HTTP server.

Functions

func NewMaxLatencyWriter

func NewMaxLatencyWriter(dst writeFlusher, latency time.Duration) *maxLatencyWriter

Types

type AccessLogRecord

type AccessLogRecord struct {
	Request       *http.Request
	Response      *http.Response
	RouteEndpoint *route.Endpoint
	StartedAt     time.Time
	FirstByteAt   time.Time
	FinishedAt    time.Time
	BodyBytesSent int64
}

func (*AccessLogRecord) Emit

func (r *AccessLogRecord) Emit(e emitter.Emitter)

func (*AccessLogRecord) FormatRequestHeader

func (r *AccessLogRecord) FormatRequestHeader(k string) (v string)

func (*AccessLogRecord) FormatStartedAt

func (r *AccessLogRecord) FormatStartedAt() string

func (*AccessLogRecord) ResponseTime

func (r *AccessLogRecord) ResponseTime() float64

func (*AccessLogRecord) WriteTo

func (r *AccessLogRecord) WriteTo(w io.Writer) (int64, error)

type AccessLogger

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

func NewAccessLogger

func NewAccessLogger(f io.Writer, loggregatorUrl string, index uint) *AccessLogger

func (*AccessLogger) Log

func (x *AccessLogger) Log(r AccessLogRecord)

func (*AccessLogger) Run

func (x *AccessLogger) Run()

func (*AccessLogger) Stop

func (x *AccessLogger) Stop()

type Flusher

type Flusher interface {
	// Flush sends any buffered data to the client.
	Flush()
}

The Flusher interface is implemented by ResponseWriters that allow an HTTP handler to flush buffered data to the client.

Note that even for ResponseWriters that support Flush, if the client is connected through an HTTP proxy, the buffered data may not reach the client until the response completes.

type Hijacker

type Hijacker interface {
	// Hijack lets the caller take over the connection.
	// After a call to Hijack(), the HTTP server library
	// will not do anything else with the connection.
	// It becomes the caller's responsibility to manage
	// and close the connection.
	Hijack() (net.Conn, *bufio.ReadWriter, error)
}

The Hijacker interface is implemented by ResponseWriters that allow an HTTP handler to take over the connection.

type Proxy

func NewProxy

func NewProxy(c *config.Config, registry *registry.Registry, v varz.Varz) *Proxy

func (*Proxy) Lookup

func (proxy *Proxy) Lookup(request *http.Request) (*route.Endpoint, bool)

func (*Proxy) ServeHTTP

func (proxy *Proxy) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)

type RequestHandler

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

func NewRequestHandler

func NewRequestHandler(request *http.Request, response http.ResponseWriter) RequestHandler

func (*RequestHandler) HandleBadGateway

func (h *RequestHandler) HandleBadGateway(err error)

func (*RequestHandler) HandleHeartbeat

func (h *RequestHandler) HandleHeartbeat()

func (*RequestHandler) HandleHttpRequest

func (h *RequestHandler) HandleHttpRequest(transport *http.Transport, endpoint *route.Endpoint) (*http.Response, error)

func (*RequestHandler) HandleMissingRoute

func (h *RequestHandler) HandleMissingRoute()

func (*RequestHandler) HandleTcpRequest

func (h *RequestHandler) HandleTcpRequest(endpoint *route.Endpoint)

func (*RequestHandler) HandleUnsupportedProtocol

func (h *RequestHandler) HandleUnsupportedProtocol()

func (*RequestHandler) HandleWebSocketRequest

func (h *RequestHandler) HandleWebSocketRequest(endpoint *route.Endpoint)

func (*RequestHandler) SetTraceHeaders

func (h *RequestHandler) SetTraceHeaders(routerIp, addr string)

func (*RequestHandler) WriteResponse

func (h *RequestHandler) WriteResponse(endpointResponse *http.Response) int64

type ResponseWriter

type ResponseWriter interface {
	// Header returns the header map that will be sent by WriteHeader.
	// Changing the header after a call to WriteHeader (or Write) has
	// no effect.
	Header() http.Header

	// Write writes the data to the connection as part of an HTTP reply.
	// If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK)
	// before writing the data.  If the Header does not contain a
	// Content-Type line, Write adds a Content-Type set to the result of passing
	// the initial 512 bytes of written data to DetectContentType.
	Write([]byte) (int, error)

	// WriteHeader sends an HTTP response header with status code.
	// If WriteHeader is not called explicitly, the first call to Write
	// will trigger an implicit WriteHeader(http.StatusOK).
	// Thus explicit calls to WriteHeader are mainly used to
	// send error codes.
	WriteHeader(int)
}

A ResponseWriter interface is used by an HTTP handler to construct an HTTP response.

type Server

type Server struct {
	Addr           string        // TCP address to listen on, ":http" if empty
	Handler        http.Handler  // handler to invoke, http.DefaultServeMux if nil
	ReadTimeout    time.Duration // maximum duration before timing out read of the request
	WriteTimeout   time.Duration // maximum duration before timing out write of the response
	MaxHeaderBytes int           // maximum size of request headers, DefaultMaxHeaderBytes if 0
}

A Server defines parameters for running an HTTP server.

func (*Server) Serve

func (srv *Server) Serve(l net.Listener) error

Serve accepts incoming connections on the Listener l, creating a new service thread for each. The service threads read requests and then call srv.Handler to reply to them.

Jump to

Keyboard shortcuts

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