MCPcopy
hub / github.com/connectrpc/connect-go / Close

Method Close

protocol_connect.go:825–844  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

823}
824
825func (hc *connectStreamingHandlerConn) Close(err error) error {
826 defer flushResponseWriter(hc.responseWriter)
827 if err := hc.marshaler.MarshalEndStream(err, hc.responseTrailer); err != nil {
828 _ = hc.request.Body.Close()
829 return err
830 }
831 // We don't want to copy unread portions of the body to /dev/null here: if
832 // the client hasn't closed the request body, we'll block until the server
833 // timeout kicks in. This could happen because the client is malicious, but
834 // a well-intentioned client may just not expect the server to be returning
835 // an error for a streaming RPC. Better to accept that we can't always reuse
836 // TCP connections.
837 if err := hc.request.Body.Close(); err != nil {
838 if connectErr, ok := asError(err); ok {
839 return connectErr
840 }
841 return NewError(CodeUnknown, err)
842 }
843 return nil // must be a literal nil: nil *Error is a non-nil error
844}
845
846type connectStreamingMarshaler struct {
847 envelopeWriter

Callers

nothing calls this directly

Calls 5

flushResponseWriterFunction · 0.85
asErrorFunction · 0.85
NewErrorFunction · 0.85
MarshalEndStreamMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected