Documentation
¶
Index ¶
- Constants
- Variables
- func NewMaxLatencyWriter(dst writeFlusher, latency time.Duration) *maxLatencyWriter
- type AccessLogRecord
- type AccessLogger
- type Flusher
- type Hijacker
- type Proxy
- type RequestHandler
- func (h *RequestHandler) HandleBadGateway(err error)
- func (h *RequestHandler) HandleHeartbeat()
- func (h *RequestHandler) HandleHttpRequest(transport *http.Transport, endpoint *route.Endpoint) (*http.Response, error)
- func (h *RequestHandler) HandleMissingRoute()
- func (h *RequestHandler) HandleTcpRequest(endpoint *route.Endpoint)
- func (h *RequestHandler) HandleUnsupportedProtocol()
- func (h *RequestHandler) HandleWebSocketRequest(endpoint *route.Endpoint)
- func (h *RequestHandler) SetTraceHeaders(routerIp, addr string)
- func (h *RequestHandler) WriteResponse(endpointResponse *http.Response) int64
- type ResponseWriter
- type Server
Constants ¶
const ( VcapTraceHeader = "X-Vcap-Trace" VcapCookieId = "__VCAP_ID__" StickyCookieKey = "JSESSIONID" )
const ( VcapBackendHeader = "X-Vcap-Backend" CfRouteEndpointHeader = "X-Cf-RouteEndpoint" VcapRouterHeader = "X-Vcap-Router" )
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.
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 ¶
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 ¶
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
type AccessLogger ¶
type AccessLogger struct {
// contains filtered or unexported fields
}
func NewAccessLogger ¶
func NewAccessLogger(f io.Writer, loggregatorUrl, loggregatorSharedSecret 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 ¶
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 (*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.