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

Method SetTimeout

protocol_grpc.go:127–139  ·  view source on GitHub ↗
(request *http.Request)

Source from the content-addressed store, hash-verified

125}
126
127func (*grpcHandler) SetTimeout(request *http.Request) (context.Context, context.CancelFunc, error) {
128 timeout, err := grpcParseTimeout(getHeaderCanonical(request.Header, grpcHeaderTimeout))
129 if err != nil && !errors.Is(err, errNoTimeout) {
130 // Errors here indicate that the client sent an invalid timeout header, so
131 // the error text is safe to send back.
132 return nil, nil, NewError(CodeInvalidArgument, err)
133 } else if err != nil {
134 // err wraps errNoTimeout, nothing to do.
135 return request.Context(), nil, nil //nolint:nilerr
136 }
137 ctx, cancel := context.WithTimeout(request.Context(), timeout)
138 return ctx, cancel, nil
139}
140
141func (g *grpcHandler) CanHandlePayload(_ *http.Request, contentType string) bool {
142 _, ok := g.accept[contentType]

Callers

nothing calls this directly

Calls 3

grpcParseTimeoutFunction · 0.85
getHeaderCanonicalFunction · 0.85
NewErrorFunction · 0.85

Tested by

no test coverage detected