MCPcopy Index your code
hub / github.com/coder/coder / WriteHeader

Method WriteHeader

coderd/tracing/status_writer.go:43–63  ·  view source on GitHub ↗
(status int)

Source from the content-addressed store, hash-verified

41}
42
43func (w *StatusWriter) WriteHeader(status int) {
44 if buildinfo.IsDev() || flag.Lookup("test.v") != nil {
45 if w.wroteHeader {
46 stack := getStackString(2)
47 wroteHeaderStack := w.wroteHeaderStack
48 if wroteHeaderStack == "" {
49 wroteHeaderStack = "unknown"
50 }
51 // It's fine that this logs to stdlib logger since it only happens
52 // in dev builds and tests.
53 log.Printf("duplicate call to (*StatusWriter.).WriteHeader(%d):\n\nstack: %s\n\nheader written at: %s", status, stack, wroteHeaderStack)
54 } else {
55 w.wroteHeaderStack = getStackString(2)
56 }
57 }
58 if !w.wroteHeader {
59 w.Status = status
60 w.wroteHeader = true
61 }
62 w.ResponseWriter.WriteHeader(status)
63}
64
65func (w *StatusWriter) Write(b []byte) (int, error) {
66 const maxBodySize = 4096

Callers 4

chatCreateWorkspaceMethod · 0.95
TestStatusWriterFunction · 0.95
Test_MiddlewareFunction · 0.95
mockTelemetryServerFunction · 0.45

Calls 2

IsDevFunction · 0.92
getStackStringFunction · 0.85

Tested by 3

TestStatusWriterFunction · 0.76
Test_MiddlewareFunction · 0.76
mockTelemetryServerFunction · 0.36