MCPcopy
hub / github.com/influxdata/telegraf / WriteHeader

Method WriteHeader

plugins/inputs/phpfpm/child.go:96–119  ·  view source on GitHub ↗

WriteHeader sends an HTTP response header with the provided status code.

(code int)

Source from the content-addressed store, hash-verified

94
95// WriteHeader sends an HTTP response header with the provided status code.
96func (r *response) WriteHeader(code int) {
97 if r.wroteHeader {
98 return
99 }
100 r.wroteHeader = true
101 if code == http.StatusNotModified {
102 // Must not have body.
103 r.header.Del("Content-Type")
104 r.header.Del("Content-Length")
105 r.header.Del("Transfer-Encoding")
106 } else if r.header.Get("Content-Type") == "" {
107 r.header.Set("Content-Type", "text/html; charset=utf-8")
108 }
109
110 if r.header.Get("Date") == "" {
111 r.header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
112 }
113
114 fmt.Fprintf(r.w, "Status: %d %s\r\n", code, http.StatusText(code))
115 //nolint:errcheck // unable to propagate
116 r.header.Write(r.w)
117 //nolint:errcheck // unable to propagate
118 r.w.WriteString("\r\n")
119}
120
121// Flush sends any buffered data to the client.
122func (r *response) Flush() {

Callers 15

WriteMethod · 0.95
FlushMethod · 0.95
TestParsingFunction · 0.80
TestCasesFunction · 0.80
TestResolverFunction · 0.80
TestGetResolverErrorsFunction · 0.80
TestAdditionalHeadersFunction · 0.80
TestServerReturnCodesFunction · 0.80
TestAuthenticationBasicFunction · 0.80
TestAuthenticationTokenFunction · 0.80
TestResolver404Function · 0.80

Calls 3

GetMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.65

Tested by 15

TestParsingFunction · 0.64
TestCasesFunction · 0.64
TestResolverFunction · 0.64
TestGetResolverErrorsFunction · 0.64
TestAdditionalHeadersFunction · 0.64
TestServerReturnCodesFunction · 0.64
TestAuthenticationBasicFunction · 0.64
TestAuthenticationTokenFunction · 0.64
TestResolver404Function · 0.64
TestGetFunction · 0.64
TestGetMultipleTimesFunction · 0.64