Response.forbidden constructor

Response.forbidden(dynamic body, { Map<String, String> headers, Encoding encoding, Map<String, Object> context })

Constructs a 403 Forbidden response.

This indicates that the server is refusing to fulfill the request.

body is the response body. It may be either a String, a List<int>, a Stream<List<int>>, or null to indicate no body.

If the body is a String, encoding is used to encode it to a Stream<List<int>>. It defaults to UTF-8. If it's a String, a List<int>, or null, the Content-Length header is set automatically unless a Transfer-Encoding header is set. Otherwise, it's a Stream<List<int>> and no Transfer-Encoding header is set, the adapter will set the Transfer-Encoding header to "chunked" and apply the chunked encoding to the body.

If encoding is passed, the "encoding" field of the Content-Type header in headers will be set appropriately. If there is no existing Content-Type header, it will be set to "application/octet-stream".

Implementation

Response.forbidden(body,
    {Map<String, String> headers,
    Encoding encoding,
    Map<String, Object> context})
    : this(403,
          headers: body == null ? _adjustErrorHeaders(headers) : headers,
          body: body == null ? 'Forbidden' : body,
          context: context,
          encoding: encoding);