Documentation ¶
Index ¶
- Variables
- type ClientConn
- func (cc *ClientConn) Close() error
- func (cc *ClientConn) Do(req *http.Request) (resp *http.Response, err error)
- func (cc *ClientConn) Hijack() (c net.Conn, r *bufio.Reader)
- func (cc *ClientConn) Pending() int
- func (cc *ClientConn) Read(req *http.Request) (resp *http.Response, err error)
- func (cc *ClientConn) Write(req *http.Request) (err error)
- type ServerConn
Constants ¶
This section is empty.
Variables ¶
var ( ErrPersistEOF = &http.ProtocolError{ErrorString: "persistent connection closed"} ErrClosed = &http.ProtocolError{ErrorString: "connection closed by user"} ErrPipeline = &http.ProtocolError{ErrorString: "pipeline error"} )
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
A ClientConn sends request and receives headers over an underlying connection, while respecting the HTTP keepalive logic. ClientConn supports hijacking the connection calling Hijack to regain control of the underlying net.Conn and deal with it as desired.
ClientConn is low-level and old. Applications should instead use Client or Transport in the net/http package.
func NewClientConn ¶
func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn
NewClientConn returns a new ClientConn reading and writing c. If r is not nil, it is the buffer to use when reading c.
ClientConn is low-level and old. Applications should use Client or Transport in the net/http package.
func NewProxyClientConn ¶
func NewProxyClientConn(c net.Conn, r *bufio.Reader) *ClientConn
NewProxyClientConn works like NewClientConn but writes Requests using Request's WriteProxy method.
New code should not use NewProxyClientConn. See Client or Transport in the net/http package instead.
func (*ClientConn) Close ¶
func (cc *ClientConn) Close() error
Close calls Hijack and then also closes the underlying connection
func (*ClientConn) Hijack ¶
func (cc *ClientConn) Hijack() (c net.Conn, r *bufio.Reader)
Hijack detaches the ClientConn and returns the underlying connection as well as the read-side bufio which may have some left over data. Hijack may be called before the user or Read have signaled the end of the keep-alive logic. The user should not call Hijack while Read or Write is in progress.
func (*ClientConn) Pending ¶
func (cc *ClientConn) Pending() int
Pending returns the number of unanswered requests that have been sent on the connection.
func (*ClientConn) Read ¶
Read reads the next response from the wire. A valid response might be returned together with an ErrPersistEOF, which means that the remote requested that this be the last request serviced. Read can be called concurrently with Write, but not with another Read.
func (*ClientConn) Write ¶
func (cc *ClientConn) Write(req *http.Request) (err error)
Write writes a request. An ErrPersistEOF error is returned if the connection has been closed in an HTTP keepalive sense. If req.Close equals true, the keepalive connection is logically closed after this request and the opposing server is informed. An ErrUnexpectedEOF indicates the remote closed the underlying TCP connection, which is usually considered as graceful close.
type ServerConn ¶
type ServerConn struct {
// contains filtered or unexported fields
}
A ServerConn reads requests and sends responses over an underlying connection, until the HTTP keepalive logic commands an end. ServerConn also allows hijacking the underlying connection by calling Hijack to regain control over the connection. ServerConn supports pipe-lining, i.e. requests can be read out of sync (but in the same order) while the respective responses are sent.
ServerConn is low-level and old. Applications should instead use Server in the net/http package.
func NewServerConn ¶
func NewServerConn(c net.Conn, r *bufio.Reader) *ServerConn
NewServerConn returns a new ServerConn reading and writing c. If r is not nil, it is the buffer to use when reading c.
ServerConn is low-level and old. Applications should instead use Server in the net/http package.
func (*ServerConn) Close ¶
func (sc *ServerConn) Close() error
Close calls Hijack and then also closes the underlying connection
func (*ServerConn) Hijack ¶
func (sc *ServerConn) Hijack() (c net.Conn, r *bufio.Reader)
Hijack detaches the ServerConn and returns the underlying connection as well as the read-side bufio which may have some left over data. Hijack may be called before Read has signaled the end of the keep-alive logic. The user should not call Hijack while Read or Write is in progress.
func (*ServerConn) Pending ¶
func (sc *ServerConn) Pending() int
Pending returns the number of unanswered requests that have been received on the connection.
func (*ServerConn) Read ¶
func (sc *ServerConn) Read() (req *http.Request, err error)
Read returns the next request on the wire. An ErrPersistEOF is returned if it is gracefully determined that there are no more requests (e.g. after the first request on an HTTP/1.0 connection, or after a Connection:close on a HTTP/1.1 connection).