Do not call from HTTP handlers. Use h.writeRawJSON/h.writeRawJSONStatus instead. writeRawJSONWithoutClientVerification takes the given bytes and always writes the response as JSON, without checking that the client can accept it.
(status int, b []byte)
| 1516 | // writeRawJSONWithoutClientVerification takes the given bytes and always writes the response as JSON, |
| 1517 | // without checking that the client can accept it. |
| 1518 | func (h *handler) writeRawJSONWithoutClientVerification(status int, b []byte) { |
| 1519 | if h.rq.Method != "HEAD" { |
| 1520 | h.setHeader("Content-Type", "application/json") |
| 1521 | if len(b) < minCompressibleJSONSize { |
| 1522 | h.disableResponseCompression() |
| 1523 | } |
| 1524 | h.setHeader("Content-Length", fmt.Sprintf("%d", len(b))) |
| 1525 | if status > 0 { |
| 1526 | h.response.WriteHeader(status) |
| 1527 | h.setStatus(status, "") |
| 1528 | } |
| 1529 | _, _ = h.response.Write(b) |
| 1530 | } else if status > 0 { |
| 1531 | h.response.WriteHeader(status) |
| 1532 | h.setStatus(status, "") |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | // writeJSON writes the given value as a JSON response with a 200 OK status. |
| 1537 | func (h *handler) writeJSON(value interface{}) { |
no test coverage detected