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

Method writeGRPC

error_writer.go:157–171  ·  view source on GitHub ↗
(response http.ResponseWriter, err error)

Source from the content-addressed store, hash-verified

155}
156
157func (w *ErrorWriter) writeGRPC(response http.ResponseWriter, err error) error {
158 trailers := make(http.Header, 2) // need space for at least code & message
159 grpcErrorToTrailer(trailers, w.protobuf, err)
160 // To make net/http reliably send trailers without a body, we must set the
161 // Trailers header rather than using http.TrailerPrefix. See
162 // https://github.com/golang/go/issues/54723.
163 keys := make([]string, 0, len(trailers))
164 for k := range trailers {
165 keys = append(keys, k)
166 }
167 setHeaderCanonical(response.Header(), headerTrailer, strings.Join(keys, ","))
168 response.WriteHeader(http.StatusOK)
169 mergeHeaders(response.Header(), trailers)
170 return nil
171}
172
173func (w *ErrorWriter) writeGRPCWeb(response http.ResponseWriter, err error) error {
174 // This is a trailers-only response. To match the behavior of Envoy and

Callers 1

WriteMethod · 0.95

Calls 5

grpcErrorToTrailerFunction · 0.85
setHeaderCanonicalFunction · 0.85
mergeHeadersFunction · 0.85
HeaderMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected