android-components / mozilla.components.concept.fetch / Response / <init>

# <init>

`Response(url: String, status: Int, headers: Headers, body: Body)`

The Response data class represents a reponse to a Request send by a Client.

You can create a Response object using the constructor, but you are more likely to encounter a Response object being returned as the result of calling Client.fetch.

A Response may hold references to other resources (e.g. streams). Therefore it's important to always close the Response object or its Body. This can be done by either consuming the content of the Body with one of the available methods or by using Kotlin's extension methods for using Closeable implementations (like `use()`):

    val response = ...
    response.use {
       // Use response. Resources will get released automatically at the end of the block.
    }