Documentation ¶
Overview ¶
Package enhttp provides an implementation of net.Conn that encapsulates traffic in one or more HTTP requests. It is conceptually similar to the older https://github.com/getlantern/enproxy but differs in that it supports HTTP servers which don't support Transfer-Encoding: Chunked on uploads.
enhttp was created to facilitate domain-fronting within Lantern.
enhttp creates virtual connections that are identified by a unique GUID. Every write to the connection is implemented as an HTTP POST. The first POST establishes the virtual connection and subsequent HTTP POSTs are tied to that connection by the X-En-Conn-Id header.
To support load-balancing, servers can optionally return an X-Server-URL header that uniquely identifies the server that handled the initial POST. If present, enhttp clients send all subsequent POSTs to that URL.
Index ¶
Constants ¶
const ( // ConnectionIDHeader identifies a virtual connection. ConnectionIDHeader = "X-En-Conn-Id" // OriginHeader identifies the origin server to which we're trying to tunnel. OriginHeader = "X-Origin" // ServerURL optionally specifies the URL to the server that handled the first // POST. ServerURL = "X-Server-URL" // Close indicates that the connection has been closed. Close = "X-Close" )
Variables ¶
This section is empty.
Functions ¶
func IsENHTTP ¶
IsENHTTP indicates whether the given candidate is an ENHTTP client connection or a wrapper around one.
func NewDialer ¶
NewDialer creates a new dialer that dials out using the enhttp protocol, tunneling via the server specified by serverURL. An http.Client must be specified to configure the underlying HTTP behavior.
func NewServerHandler ¶
NewServerHandler creates an http.Handler that performs the server-side processing of enhttp. reapIdleTime specifies the amount of time a connection is allowed to remain idle before being forcibly closed. serverURL optionally specifies the unique URL at which this server can be reached (used for sticky routing).
func OriginHost ¶
OriginHost extracts the origin from the given request, using X-Origin header if available otherwise using the Host header.
Types ¶
This section is empty.