Package io.ktor.http
Types
sealed class CacheControl Represents a value for a |
|
class ContentDisposition : HeaderValueWithParameters Represents |
|
sealed class ContentRange Represents a |
|
class ContentType : HeaderValueWithParameters Represents a value for a |
|
interface ContentTypeMatcher Interface for any objects that can match a ContentType. |
|
data class Cookie Represents a cookie with name, content and a set of settings such as expiration, visibility and security. A cookie with neither expires nor maxAge is a session cookie. |
|
enum class CookieEncoding Cooke encoding strategy |
|
object |
|
object |
|
data class HeaderValue Represents a header value. Similar to HeaderValueWithParameters |
|
data class HeaderValueParam Represents a single value parameter |
|
abstract class HeaderValueWithParameters Represents a header value that consist of content followed by parameters.
Useful for headers such as |
|
interface Headers : StringValues Represents HTTP headers as a map from case-insensitive names to collection of String values |
|
class HeadersBuilder : StringValuesBuilder |
|
class HeadersImpl : Headers, StringValuesImpl |
|
class HeadersSingleImpl : Headers, StringValuesSingleImpl |
|
object HttpHeaders |
|
interface HttpMessage A message either from the client or the server, that has headers associated. |
|
interface HttpMessageBuilder A builder message either for the client or the server, that has a headers builder associated. |
|
data class HttpMethod Represents an HTTP method (verb) |
|
data class HttpProtocolVersion Represents an HTTP protocol version. |
|
data class HttpStatusCode Represents an HTTP status code and description. |
|
class LinkHeader : HeaderValueWithParameters Represents a |
|
interface Parameters : StringValues Represents HTTP parameters as a map from case-insensitive names to collection of String values |
|
class ParametersBuilder : StringValuesBuilder |
|
class ParametersImpl : Parameters, StringValuesImpl |
|
class ParametersSingleImpl : |
|
enum class RangeUnits Possible content range units: bytes and none |
|
data class RangesSpecifier Range specifier for partial content requests (RFC 2616 sec 14.35.1) |
|
interface RequestConnectionPoint Represents request address information is used to make a call. There are at least two possible instances: “local” is how we see request at the server application and “actual” is what we can recover from proxy provided headers. |
|
class URLBuilder A URL builder with all mutable components |
|
data class URLProtocol Represents URL protocol |
|
data class Url Represents an immutable URL |
Exceptions
class BadContentTypeFormatException : Exception Exception thrown when a content type string is malformed. |
|
class IllegalHeaderNameException : IllegalArgumentException Thrown when an illegal header name was used.
A header name should only consist from visible characters
without delimiters “double quote” and the following characters: |
|
class IllegalHeaderValueException : IllegalArgumentException Thrown when an illegal header value was used. A header value should only consist from visible characters, spaces and/or HTAB (0x09). |
|
class URLDecodeException : Exception URL decoder exception |
|
class URLParserException : IllegalStateException Thrown when failed to parse URL |
|
class UnsafeHeaderException : IllegalArgumentException Thrown when an attempt to set unsafe header detected. A header is unsafe if listed in HttpHeaders.UnsafeHeadersList. |
Extensions for External Classes
Properties
const val DEFAULT_PORT: Int Select default port value from protocol. |
|
Url authority. val URLBuilder.authority: String URLBuilder authority. |
|
Full encoded path with query string but without domain, port and schema |
|
Host:port pair, not normalized so port is always specified even if the port is schema’s default |
|
val httpDateFormat: DateTimeFormatter Default HTTP date format |
|
val Default HTTP date format |
Functions
fun URLBuilder(urlString: String): URLBuilder Construct URLBuilder from urlString. fun URLBuilder(url: Url): URLBuilder Construct URLBuilder from url. fun URLBuilder(builder: URLBuilder): URLBuilder Construct URLBuilder from builder. |
|
fun Url(builder: URLBuilder): Url |
|
fun StringValuesBuilder.append( Append formatted header value to the builder |
|
fun HttpMessage.cacheControl(): List<HeaderValue> Parse |
|
fun HeaderValueWithParameters.charset(): Charset? Extracts a Charset value from the given fun HttpMessageBuilder. fun HttpMessageBuilder.charset(): Charset? fun HttpMessage.charset(): Charset? Parse charset from |
|
fun URLBuilder.clone(): URLBuilder Create a copy of this builder. Modifications in a copy is not reflected in the original instance and vise-versa. |
|
fun HttpMessageBuilder. fun HttpMessageBuilder.contentLength(): Long? fun HttpMessage.contentLength(): Long? Parse |
|
fun contentRangeHeaderValue( fun contentRangeHeaderValue( Format |
|
fun HttpMessageBuilder.contentType(type: ContentType): Unit Set fun HttpMessageBuilder.contentType(): ContentType? fun HttpMessage.contentType(): ContentType? Parse |
|
fun HttpMessageBuilder.cookies(): List<Cookie> Parse |
|
fun HttpMessage.date(): Date? Parse |
|
fun decodeCookieValue( Decode cookie value using the specified encoding |
|
fun encodeCookieValue( Encode cookie value using the specified encoding |
|
fun HeadersBuilder.etag(entityTag: String): Unit Set fun HttpMessageBuilder.etag(): String? fun HttpMessage.etag(): String? Parse |
|
fun HttpMessageBuilder.expires(): Date? fun HttpMessage.expires(): Date? Parse fun HeadersBuilder.expires(expires: LocalDateTime): Unit Set ‘Expires` header value from expires |
|
fun ContentType.fileExtensions(): List<String> Recommended file name extensions for this content type |
|
fun Parameters.formUrlEncode(): String Encode form parameters |
|
fun Parameters.formUrlEncodeTo(out: Appendable): Unit Encode form parameters to the specified out appendable |
|
fun headersOf(): Headers Returns empty headers Returns Headers instance containing only one header with the specified name and value Returns Headers instance containing only one header with the specified name and values |
|
Check if host is IPv4 or IPv6 address. |
|
fun HttpMessageBuilder.ifModifiedSince(date: Date): Unit Set |
|
fun HttpMessageBuilder.ifNoneMatch(value: String): Unit Set |
|
fun URLProtocol.isSecure(): Boolean Check if the protocol is secure |
|
fun HttpStatusCode.isSuccess(): Boolean Checks if a given status code is a success code according to HTTP standards. |
|
fun URLProtocol.isWebsocket(): Boolean Check if the protocol is websocket |
|
fun HttpMessageBuilder.lastModified(): Date? fun HttpMessage.lastModified(): Date? Parse fun HeadersBuilder.lastModified( Set ‘Last-Modified` header value from dateTime |
|
fun ApplicationResponse.link(header: LinkHeader): Unit Append fun ApplicationResponse.link( Append |
|
fun HttpMessageBuilder.maxAge(seconds: Int): Unit Append |
|
fun parametersOf(): Parameters Returns an empty parameters instance fun parametersOf(name: String, value: String): Parameters Creates a parameters instance containing only single pair fun parametersOf( Creates a parameters instance containing only single pair of name with multiple values fun parametersOf( Creates a parameters instance from the specified pairs |
|
fun parseAndSortContentTypeHeader( Parse |
|
fun parseAndSortHeader(header: String?): List<HeaderValue> Parse header value and sort multiple values according to qualities |
|
fun parseClientCookiesHeader( Parse client’s |
|
fun parseHeaderValue(text: String?): List<HeaderValue> fun parseHeaderValue( Parse header value respecting multi-values |
|
fun parseQueryString( Parse query string withing starting at the specified startIndex but up to limit pairs |
|
fun parseRangesSpecifier(rangeSpec: String): RangesSpecifier? Parse |
|
Parse server’s |
|
operator fun Parameters.plus(other: Parameters): Parameters Plus operator function that creates a new parameters instance from the original one concatenating with other |
|
fun ApplicationCall.push(pathAndQuery: String): Unit fun ApplicationCall.push( Produces HTTP/2 push from server to client or sets HTTP/1.x hint header or does nothing. Exact behaviour is up to engine implementation. fun ApplicationCall.push( Produces HTTP/2 push from server to client or sets HTTP/1.x hint header or does nothing (may call or not call block). Exact behaviour is up to engine implementation. |
|
Format |
|
fun renderSetCookieHeader( Format |
|
fun HttpMessage.setCookie(): List<Cookie> Parse |
|
fun URLBuilder.takeFrom(urlString: String): URLBuilder Take url parts from urlString throws URLParserException fun URLBuilder.takeFrom(url: URLBuilder): URLBuilder Take components from another url builder fun URLBuilder.takeFrom(url: Url): URLBuilder Take components from another url fun URLBuilder.takeFrom(uri: URI): URLBuilder Take URI components from uri fun URLBuilder.takeFrom(url: URL): URLBuilder Take URI components from url |
|
fun HttpMessageBuilder.userAgent(content: String): Unit Set |
|
fun HttpMessageBuilder.vary(): List<String>? fun HttpMessage.vary(): List<String>? Parse |
|
fun ContentType.withCharset(charset: Charset): ContentType Creates a copy of |
Companion Object Properties
val HttpStatusCode.Companion. |
Companion Object Functions
fun ContentType.Companion.defaultForFile( fun ContentType.Companion.defaultForFile( |
|
fun ContentType.Companion.defaultForFileExtension( Default ContentType for extension |
|
fun ContentType.Companion.defaultForFilePath( Default ContentType for file path |
|
fun ContentType.Companion.fromFileExtension( Recommended content type by file name extension |
|
fun ContentType.Companion.fromFilePath( Recommended content types by file path |
|