Header
annotation class Header(@Language(value = "http-header-reference"
Add a header to a request
@Header("Accept", "application/json")
@Header("Content-Type", "application/json")
@POST("comments")
suspend fun request(@Body comments: List<Comment>): List<Comment>
// type-safe
@Header(Header.Accept, Header.ContentTypes.Application.Json)
@GET("comments")
suspend fun request(): List<Comment>
Content copied to clipboard
By default, Headers do not overwrite each other: all headers with the same name will be included in the request. Except headers mentioned as singleton, e.g. Content-Type
Migration from other libraries: Use @HeaderParam for parameters
See also
Types
Link copied to clipboard
object AcceptEncodings
Contain commonly used Accept-Encoding
values.
Link copied to clipboard
object ContentTypes
Contain common types of header Content-Type
subdivide in objects as Type/Subtype