Response.unauthorized constructor

Response.unauthorized({
  1. Body? body,
  2. Headers? headers,
})

Constructs a 401 Unauthorized response.

This indicates indicates that the client request has not been completed because it lacks valid authentication credentials.

body is the response body. It may be a Body instance or null to indicate no body. Use Body.fromString, Body.fromBytes, or Body.fromDataStream to create the body with the appropriate content type and encoding.

headers must contain values that are either String or List<String>. An empty list will cause the header to be omitted.

Implementation

Response.unauthorized({Body? body, Headers? headers})
  : this(
      401,
      headers: headers ?? Headers.empty(),
      body: body ?? Body.fromString('Unauthorized'),
    );