MCPcopy Index your code
hub / github.com/subtrace/subtrace / sendResponse

Method sendResponse

devtools/devtools.go:270–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

268}
269
270func (w *pipeResponseWriter) sendResponse() {
271 if w.sentResponse {
272 return
273 }
274 w.sentResponse = true
275
276 if w.hasContent {
277 w.resp.ContentLength = -1
278 }
279
280 if w.Header().Get("upgrade") == "websocket" {
281 // Safari has a weird bug where HTTP/1.0 connections that upgrade to
282 // Websocket don't work but HTTP/1.1 connections do, hence this ugly
283 // workaround.
284 //
285 // We want the websocket request to use HTTP/1.1 but we don't
286 // want the HTML response to use HTTP/1.1 because we don't want the client
287 // to reuse the HTML request connection (our dumb HTTP hijacker can't do
288 // complex things). But HTTP/1.1 connection reuse semantics don't matter
289 // for the websocket response because 101 Switching Protocols means the
290 // previous protocol (HTTP/1.1) doesn't matter anymore.
291 //
292 // Safari, why can't you just be normal?
293 w.resp.ProtoMinor = 1
294 }
295
296 go func() {
297 defer close(w.done)
298 w.errs <- w.resp.Write(w.conn)
299 }()
300}
301
302func (w *pipeResponseWriter) Header() http.Header {
303 return w.resp.Header

Callers 3

finishMethod · 0.95
WriteMethod · 0.95
HijackMethod · 0.95

Calls 3

HeaderMethod · 0.95
WriteMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected