| 34 | } |
| 35 | |
| 36 | func (rw *responseWriter) WriteHeader(statusCode int) { |
| 37 | if rw.written { |
| 38 | return |
| 39 | } |
| 40 | rw.status = statusCode |
| 41 | rw.written = true |
| 42 | |
| 43 | statusText := http.StatusText(statusCode) |
| 44 | if statusText == "" { |
| 45 | statusText = fmt.Sprintf("status code %d", statusCode) |
| 46 | } |
| 47 | _, _ = fmt.Fprintf(rw.conn, "HTTP/1.1 %d %s\r\n", statusCode, statusText) |
| 48 | _ = rw.headers.Write(rw.conn) |
| 49 | _, _ = rw.conn.Write([]byte("\r\n")) |
| 50 | } |
| 51 | |
| 52 | func (rw *responseWriter) Write(data []byte) (int, error) { |
| 53 | if !rw.written { |