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

Method Write

coderd/tracing/status_writer.go:65–84  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

63}
64
65func (w *StatusWriter) Write(b []byte) (int, error) {
66 const maxBodySize = 4096
67
68 if !w.wroteHeader {
69 w.Status = http.StatusOK
70 w.wroteHeader = true
71 }
72
73 if w.Status >= http.StatusBadRequest {
74 // This is technically wrong as multiple calls to write
75 // will simply overwrite w.ResponseBody but given that
76 // we typically only write to the response body once
77 // and this field is only used for logging I'm leaving
78 // this as-is.
79 w.responseBody = make([]byte, minInt(len(b), maxBodySize))
80 copy(w.responseBody, b)
81 }
82
83 return w.ResponseWriter.Write(b)
84}
85
86func minInt(a, b int) int {
87 if a < b {

Callers 1

TestStatusWriterFunction · 0.95

Calls 2

minIntFunction · 0.85
WriteMethod · 0.65

Tested by 1

TestStatusWriterFunction · 0.76