{
  "id": "38daa09938ee5138c4c2f46c",
  "source": "http",
  "type": "go-type",
  "title": "http.type ResponseWriter ¶",
  "content": "# type http.type ResponseWriter ¶\n\n```\ntype ResponseWriter interface {\n\t// Header returns the header map that will be sent by\n\t// [ResponseWriter.WriteHeader]. The [Header] map also is the mechanism with which\n\t// [Handler] implementations can set HTTP trailers.\n\t//\n\t// Changing the header map after a call to [ResponseWriter.WriteHeader] (or\n\t// [ResponseWriter.Write]) has no effect unless the HTTP status code was of the\n\t// 1xx class or the modified headers are trailers.\n\t//\n\t// There are two ways to set Trailers. The preferred way is to\n\t// predeclare in the headers which trailers you will later\n\t// send by setting the \"Trailer\" header to the names of the\n\t// trailer keys which will come later. In this case, those\n\t// keys of the Header map are treated as if they were\n\t// trailers. See the example. The second way, for trailer\n\t// keys not known to the [Handler] until after the first [ResponseWriter.Write],\n\t// is to prefix the [Header] map keys with the [TrailerPrefix]\n\t// constant value.\n\t//\n\t// To suppress automatic response headers (such as \"Date\"), set\n\t// their value to nil.\n\tHeader() Header\n\n\t// Write writes the data to the connection as part of an HTTP reply.\n\t//\n\t// If [ResponseWriter.WriteHeader] has not yet been called, Write calls\n\t// WriteHeader(http.StatusOK) before writing the data. If the Header\n\t// does not contain a Content-Type line, Write adds a Content-Type set\n\t// to the result of passing the initial 512 bytes of written data to\n\t// [DetectContentType]. Additionally, if the total size of all written\n\t// data is under a few KB and there are no Flush calls, the\n\t// Content-Length header is added automatically.\n\t//\n\t// Depending on the HTTP protocol version and the client, calling\n\t// Write or WriteHeader may prevent future reads on the\n\t// Request.Body. For HTTP/1.x requests, handlers should read any\n\t// needed request body data before writing the response. Once the\n\t// headers have been flushed (due to either an explicit Flusher.Flush\n\t// call or writing enough data to trigger a flush), the request body\n\t// may be unavailable. For HTTP/2 requests, the Go HTTP server permits\n\t// handlers to continue to read the request body while concurrently\n\t// writing the response. However, such behavior may not be supported\n\t// by all HTTP/2 clients. Handlers should read before writing if\n\t// possible to maximize compatibility.\n\tWrite([]byte) (int, error)\n\n\t// WriteHeader sends an HTTP response header with the provided\n\t// status code.\n\t//\n\t// If WriteHeader is not called explicitly, the first call to Write\n\t// will trigger an implicit WriteHeader(http.StatusOK).\n\t// Thus explicit calls to WriteHeader are mainly used to\n\t// send error codes or 1xx informational responses.\n\t//\n\t// The provided code must be a valid HTTP 1xx-5xx status code.\n\t// Any number of 1xx headers may be written, followed by at most\n\t// one 2xx-5xx header. 1xx headers are sent immediately, but 2xx-5xx\n\t// headers may be buffered. Use the Flusher interface to send\n\t// buffered data. The header map is cleared when 2xx-5xx headers are\n\t// sent, but not with 1xx headers.\n\t//\n\t// The server will automatically send a 100 (Continue) header\n\t// on the first read from the request body if the request has\n\t// an \"Expect: 100-continue\" header.\n\tWriteHeader(statusCode int)\n}\n```\n\nA ResponseWriter interface is used by an HTTP handler to\nconstruct an HTTP response.",
  "url": "https://pkg.go.dev/http#type ResponseWriter ¶",
  "metadata": {
    "fields": "null",
    "import_path": "Standard library/net/http",
    "kind": "type",
    "method_count": 0,
    "package": "http",
    "symbol": "type ResponseWriter ¶",
    "type_kind": "alias",
    "underlying": "type ResponseWriter interface {\n\t// Header returns the header map that will be sent by\n\t// [ResponseWriter.WriteHeader]. The [Header] map also is the mechanism with which\n\t// [Handler] implementations can set HTTP trailers.\n\t//\n\t// Changing the header map after a call to [ResponseWriter.WriteHeader] (or\n\t// [ResponseWriter.Write]) has no effect unless the HTTP status code was of the\n\t// 1xx class or the modified headers are trailers.\n\t//\n\t// There are two ways to set Trailers. The preferred way is to\n\t// predeclare in the headers which trailers you will later\n\t// send by setting the \"Trailer\" header to the names of the\n\t// trailer keys which will come later. In this case, those\n\t// keys of the Header map are treated as if they were\n\t// trailers. See the example. The second way, for trailer\n\t// keys not known to the [Handler] until after the first [ResponseWriter.Write],\n\t// is to prefix the [Header] map keys with the [TrailerPrefix]\n\t// constant value.\n\t//\n\t// To suppress automatic response headers (such as \"Date\"), set\n\t// their value to nil.\n\tHeader() Header\n\n\t// Write writes the data to the connection as part of an HTTP reply.\n\t//\n\t// If [ResponseWriter.WriteHeader] has not yet been called, Write calls\n\t// WriteHeader(http.StatusOK) before writing the data. If the Header\n\t// does not contain a Content-Type line, Write adds a Content-Type set\n\t// to the result of passing the initial 512 bytes of written data to\n\t// [DetectContentType]. Additionally, if the total size of all written\n\t// data is under a few KB and there are no Flush calls, the\n\t// Content-Length header is added automatically.\n\t//\n\t// Depending on the HTTP protocol version and the client, calling\n\t// Write or WriteHeader may prevent future reads on the\n\t// Request.Body. For HTTP/1.x requests, handlers should read any\n\t// needed request body data before writing the response. Once the\n\t// headers have been flushed (due to either an explicit Flusher.Flush\n\t// call or writing enough data to trigger a flush), the request body\n\t// may be unavailable. For HTTP/2 requests, the Go HTTP server permits\n\t// handlers to continue to read the request body while concurrently\n\t// writing the response. However, such behavior may not be supported\n\t// by all HTTP/2 clients. Handlers should read before writing if\n\t// possible to maximize compatibility.\n\tWrite([]byte) (int, error)\n\n\t// WriteHeader sends an HTTP response header with the provided\n\t// status code.\n\t//\n\t// If WriteHeader is not called explicitly, the first call to Write\n\t// will trigger an implicit WriteHeader(http.StatusOK).\n\t// Thus explicit calls to WriteHeader are mainly used to\n\t// send error codes or 1xx informational responses.\n\t//\n\t// The provided code must be a valid HTTP 1xx-5xx status code.\n\t// Any number of 1xx headers may be written, followed by at most\n\t// one 2xx-5xx header. 1xx headers are sent immediately, but 2xx-5xx\n\t// headers may be buffered. Use the Flusher interface to send\n\t// buffered data. The header map is cleared when 2xx-5xx headers are\n\t// sent, but not with 1xx headers.\n\t//\n\t// The server will automatically send a 100 (Continue) header\n\t// on the first read from the request body if the request has\n\t// an \"Expect: 100-continue\" header.\n\tWriteHeader(statusCode int)\n}"
  },
  "hash": "a25d19197b587b899ad5ce2069c49fd98afbff959dd846ad59cfa38e1f8d1cfa",
  "timestamp": "2026-02-19T12:17:17.237715276+01:00"
}