MCPcopy
hub / github.com/caddyserver/caddy / Write

Method Write

modules/caddyhttp/reverseproxy/fastcgi/writer.go:46–71  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

44}
45
46func (w *streamWriter) Write(p []byte) (int, error) {
47 // init header
48 if w.buf.Len() < 8 {
49 w.buf.Write(pad[:8])
50 }
51
52 nn := 0
53 for len(p) > 0 {
54 n := len(p)
55 nl := maxWrite + 8 - w.buf.Len()
56 if n > nl {
57 n = nl
58 w.buf.Write(p[:n])
59 if err := w.Flush(); err != nil {
60 return nn, err
61 }
62 // reset headers
63 w.buf.Write(pad[:8])
64 } else {
65 w.buf.Write(p[:n])
66 }
67 nn += n
68 p = p[n:]
69 }
70 return nn, nil
71}
72
73func (w *streamWriter) endStream() error {
74 // send empty record to close the stream

Callers 6

generateRandFileFunction · 0.45
RoundTripMethod · 0.45
CloseMethod · 0.45
writeRecordMethod · 0.45
writePairsMethod · 0.45
FlushMethod · 0.45

Calls 2

FlushMethod · 0.95
LenMethod · 0.45

Tested by 1

generateRandFileFunction · 0.36