Documentation
¶
Index ¶
- type DuplexHTTPCall
- func (d *DuplexHTTPCall) BlockUntilResponseReady() error
- func (d *DuplexHTTPCall) CloseRead() error
- func (d *DuplexHTTPCall) CloseWrite() error
- func (d *DuplexHTTPCall) Header() http.Header
- func (d *DuplexHTTPCall) Method() string
- func (d *DuplexHTTPCall) Read(data []byte) (int, error)
- func (d *DuplexHTTPCall) ResponseHeader() http.Header
- func (d *DuplexHTTPCall) ResponseStatusCode() (int, error)
- func (d *DuplexHTTPCall) ResponseTrailer() http.Header
- func (d *DuplexHTTPCall) Send(payload MessagePayload) (int64, error)
- func (d *DuplexHTTPCall) SetMethod(method string)
- func (d *DuplexHTTPCall) SetValidateResponse(validate func(*http.Response) error)
- func (d *DuplexHTTPCall) Trailer() http.Header
- func (d *DuplexHTTPCall) URL() *url.URL
- type HTTPClient
- type MessagePayload
- type MessageSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DuplexHTTPCall ¶
type DuplexHTTPCall struct {
OnRequestSend func(*http.Request)
// contains filtered or unexported fields
}
DuplexHTTPCall is a full-duplex stream between the client and server. The request body is the stream from client to server, and the response body is the reverse.
Be warned: we need to use some lesser-known APIs to do this with net/http.
func NewDuplexHTTPCall ¶
func NewDuplexHTTPCall(ctx context.Context, httpClient HTTPClient, url *url.URL, sendUnary bool, header http.Header) *DuplexHTTPCall
func (*DuplexHTTPCall) BlockUntilResponseReady ¶
func (d *DuplexHTTPCall) BlockUntilResponseReady() error
BlockUntilResponseReady returns when the response is ready or reports an error from initializing the request.
func (*DuplexHTTPCall) CloseRead ¶
func (d *DuplexHTTPCall) CloseRead() error
CloseRead closes the response body.
func (*DuplexHTTPCall) CloseWrite ¶
func (d *DuplexHTTPCall) CloseWrite() error
CloseWrite closes the request body. Callers *must* call CloseWrite before Read when using HTTP/1.x.
func (*DuplexHTTPCall) Header ¶
func (d *DuplexHTTPCall) Header() http.Header
Header returns the HTTP request headers.
func (*DuplexHTTPCall) Method ¶
func (d *DuplexHTTPCall) Method() string
Method returns the HTTP method for the request (GET or POST).
func (*DuplexHTTPCall) Read ¶
func (d *DuplexHTTPCall) Read(data []byte) (int, error)
Read from the response body. Returns the first error passed to SetError.
func (*DuplexHTTPCall) ResponseHeader ¶
func (d *DuplexHTTPCall) ResponseHeader() http.Header
ResponseHeader returns the response HTTP headers.
func (*DuplexHTTPCall) ResponseStatusCode ¶
func (d *DuplexHTTPCall) ResponseStatusCode() (int, error)
ResponseStatusCode is the response's HTTP status code.
func (*DuplexHTTPCall) ResponseTrailer ¶
func (d *DuplexHTTPCall) ResponseTrailer() http.Header
ResponseTrailer returns the response HTTP trailers.
func (*DuplexHTTPCall) Send ¶
func (d *DuplexHTTPCall) Send(payload MessagePayload) (int64, error)
Send sends a message to the server.
func (*DuplexHTTPCall) SetMethod ¶
func (d *DuplexHTTPCall) SetMethod(method string)
SetMethod changes the method of the request before it is sent.
func (*DuplexHTTPCall) SetValidateResponse ¶
func (d *DuplexHTTPCall) SetValidateResponse(validate func(*http.Response) error)
SetValidateResponse sets the response validation function. The function runs in a background goroutine.
func (*DuplexHTTPCall) Trailer ¶
func (d *DuplexHTTPCall) Trailer() http.Header
Trailer returns the HTTP request trailers.
func (*DuplexHTTPCall) URL ¶
func (d *DuplexHTTPCall) URL() *url.URL
URL returns the URL for the request.
type HTTPClient ¶
HTTPClient is the interface connect expects HTTP clients to implement. The standard library's *http.Client implements HTTPClient.
type MessagePayload ¶
MessagePayload is a sized and seekable message payload. The interface is implemented by *bytes.Reader and *envelope. Reads must be non-blocking.
type MessageSender ¶
type MessageSender interface {
Send(MessagePayload) (int64, error)
}
MessageSender sends a message payload.