Package-level declarations

Types

Link copied to clipboard

Exception thrown when a content type string is malformed.

Link copied to clipboard
abstract class CacheControl(val visibility: CacheControl.Visibility?)

Represents a value for a Cache-Control header

Link copied to clipboard
class ContentDisposition(disposition: String, val parameters: List<HeaderValueParam> = emptyList()) : HeaderValueWithParameters

Represents Content-Disposition header value

Link copied to clipboard
sealed class ContentRange

Represents a Range header's particular range

Link copied to clipboard

Represents a value for a Content-Type header.

Link copied to clipboard

Interface for any objects that can match a ContentType.

Link copied to clipboard
data class Cookie(val name: String, val value: String, val encoding: CookieEncoding = CookieEncoding.URI_ENCODING, val maxAge: Int = 0, val expires: GMTDate? = null, val domain: String? = null, val path: String? = null, val secure: Boolean = false, val httpOnly: Boolean = false, val extensions: Map<String, String?> = emptyMap())

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.

Link copied to clipboard

Cooke encoding strategy

Link copied to clipboard
Link copied to clipboard
interface Headers : StringValues

Represents HTTP headers as a map from case-insensitive names to collection of String values

Link copied to clipboard
Link copied to clipboard
class HeadersImpl(values: Map<String, List<String>> = emptyMap()) : StringValuesImpl, Headers
Link copied to clipboard
Link copied to clipboard
data class HeaderValue(val value: String, val params: List<HeaderValueParam> = emptyList())

Represents a header value. Similar to HeaderValueWithParameters

Link copied to clipboard
data class HeaderValueParam(val name: String, val value: String, val escapeValue: Boolean)

Represents a single value parameter

Link copied to clipboard
abstract class HeaderValueWithParameters(content: String, val parameters: List<HeaderValueParam> = emptyList())

Represents a header value that consist of content followed by parameters. Useful for headers such as Content-Type, Content-Disposition and so on.

Link copied to clipboard
Link copied to clipboard
interface HttpMessage

A message either from the client or the server, that has headers associated.

Link copied to clipboard

A builder message either for the client or the server, that has a headers builder associated.

Link copied to clipboard
data class HttpMethod(val value: String)

Represents an HTTP method (verb)

Link copied to clipboard
data class HttpProtocolVersion(val name: String, val major: Int, val minor: Int)

Represents an HTTP protocol version.

Link copied to clipboard
data class HttpStatusCode(val value: Int, val description: String)

Represents an HTTP status code and description.

Link copied to clipboard
class IllegalHeaderNameException(val headerName: String, val position: Int) : 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: (),/:;<=>?@[\]{}.

Link copied to clipboard
class IllegalHeaderValueException(val headerValue: String, val position: Int) : IllegalArgumentException

Thrown when an illegal header value was used. A header value should only consist from visible characters, spaces and/or HTAB (0x09).

Link copied to clipboard

Represents a Link header value as per RFC 5988

Link copied to clipboard

Represents HTTP parameters as a map from case-insensitive names to collection of String values

Link copied to clipboard
Link copied to clipboard
class ParametersImpl(values: Map<String, List<String>> = emptyMap()) : StringValuesImpl, Parameters
Link copied to clipboard
Link copied to clipboard
data class RangesSpecifier(val unit: String = RangeUnits.Bytes.unitToken, val ranges: List<ContentRange>)

Range specifier for partial content requests (RFC 2616 sec 14.35.1)

Link copied to clipboard

Possible content range units: bytes and none

Link copied to clipboard

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.

Link copied to clipboard

Thrown when an attempt to set unsafe header detected. A header is unsafe if listed in HttpHeaders.UnsafeHeadersList.

Link copied to clipboard
class Url

Represents an immutable URL

Link copied to clipboard
class URLBuilder(var protocol: URLProtocol = URLProtocol.HTTP, var host: String = "", var port: Int = DEFAULT_PORT, user: String? = null, password: String? = null, pathSegments: List<String> = emptyList(), parameters: Parameters = Parameters.Empty, fragment: String = "", var trailingQuery: Boolean = false)

A URL builder with all mutable components

Link copied to clipboard

URL decoder exception

Link copied to clipboard

Thrown when failed to parse URL

Link copied to clipboard
data class URLProtocol(val name: String, val defaultPort: Int)

Represents URL protocol

Functions

Link copied to clipboard

Append formatted header value to the builder

Link copied to clipboard
fun URLBuilder.appendPathSegments(vararg components: String, encodeSlash: Boolean = false): URLBuilder

Adds components to current encodedPath

fun URLBuilder.appendPathSegments(segments: List<String>, encodeSlash: Boolean = false): URLBuilder

Adds segments to current encodedPath.

Link copied to clipboard
fun Appendable.appendUrlFullPath(encodedPath: String, encodedQueryParameters: ParametersBuilder, trailingQuery: Boolean)
Link copied to clipboard

Parse CacheControl header.

Link copied to clipboard

Extracts a Charset value from the given Content-Type, Content-Disposition or similar header value.

Parse charset from Content-Type header value.

Link copied to clipboard

Create a copy of this builder. Modifications in a copy is not reflected in the original instance and vise-versa.

Link copied to clipboard

Parse Content-Length header value.

Link copied to clipboard
fun contentRangeHeaderValue(range: LongRange?, fullLength: Long? = null, unit: RangeUnits = RangeUnits.Bytes): String
fun contentRangeHeaderValue(range: LongRange?, fullLength: Long? = null, unit: String = RangeUnits.Bytes.unitToken): String

Format Content-Range header value

Link copied to clipboard

Parse Content-Type header value.

Set Content-Type header.

Link copied to clipboard

Parse Set-Cookie header value.

Link copied to clipboard
fun Url.copy(protocol: URLProtocol = this.protocol, host: String = this.host, specifiedPort: Int = this.specifiedPort, encodedPath: String = this.encodedPath, parameters: Parameters = this.parameters, fragment: String = this.fragment, user: String? = this.user, password: String? = this.password, trailingQuery: Boolean = this.trailingQuery): Url
Link copied to clipboard

Parse Date header.

Link copied to clipboard
fun decodeCookieValue(encodedValue: String, encoding: CookieEncoding): String

Decode cookie value using the specified encoding

Link copied to clipboard
fun String.decodeURLPart(start: Int = 0, end: Int = length, charset: Charset = Charsets.UTF_8): String

Decode percent encoded URL part within the specified range [start, end). This function is not intended to decode urlencoded forms so it doesn't decode plus character to space.

Link copied to clipboard
fun String.decodeURLQueryComponent(start: Int = 0, end: Int = length, plusIsSpace: Boolean = false, charset: Charset = Charsets.UTF_8): String

Decode URL query component

Link copied to clipboard
Link copied to clipboard

Encode cookie value using the specified encoding

Link copied to clipboard

Encode this in percent encoding specified here: https://tools.ietf.org/html/rfc5849#section-3.6

Link copied to clipboard
fun String.encodeURLParameter(spaceToPlus: Boolean = false): String

Encode this as query parameter key.

Link copied to clipboard

Encodes URL path. It escapes all illegal or ambiguous characters keeping all "/" symbols.

Link copied to clipboard

Encodes URL path segment. It escapes all illegal or ambiguous characters

Link copied to clipboard
fun String.encodeURLQueryComponent(encodeFull: Boolean = false, spaceToPlus: Boolean = false, charset: Charset = Charsets.UTF_8): String

Encode url part as specified in https://tools.ietf.org/html/rfc3986#section-2

Link copied to clipboard

Escape using double quotes if needed or keep as is if no dangerous strings found

Link copied to clipboard

Parse E-Tag header value.

fun HeadersBuilder.etag(entityTag: String)

Set E-Tag header

Link copied to clipboard

Parse Expires header.

Link copied to clipboard

Recommended file name extensions for this content type

Link copied to clipboard

Encode form parameters

Encode form parameters from a list of pairs

Link copied to clipboard

Encode form parameters to the specified out appendable

Encode form parameters from a list of pairs to the specified out appendable

Link copied to clipboard

Convert valid cookie date String to GMTDate trying first the RFC6265 standard, falling back on fromHttpToGmtDate

Link copied to clipboard

Recommended content type by file name extension

Link copied to clipboard

Recommended content types by file path

Link copied to clipboard

Convert valid http date String to GMTDate trying various http date formats from HTTP_DATE_FORMATS

Link copied to clipboard

Returns empty headers

fun headersOf(vararg pairs: Pair<String, List<String>>): Headers

Returns Headers instance from pairs

fun headersOf(name: String, value: String): Headers

Returns Headers instance containing only one header with the specified name and value

fun headersOf(name: String, values: List<String>): Headers

Returns Headers instance containing only one header with the specified name and values

Link copied to clipboard
fun hostIsIp(host: String): Boolean

Check if host is IPv4 or IPv6 address.

Link copied to clipboard

Set If-Modified-Since header.

Link copied to clipboard

Set If-None-Match header value.

Link copied to clipboard
operator fun Url.Companion.invoke(fullUrl: String): Url

Construct Url from String

Link copied to clipboard

Check if the protocol is secure

Link copied to clipboard

Checks if a given status code is a success code according to HTTP standards.

Link copied to clipboard

Check if the protocol is websocket

Link copied to clipboard

Parse Last-Modified header.

Link copied to clipboard

Append Max-Age header value.

Link copied to clipboard
Link copied to clipboard

Returns an empty parameters instance

fun parametersOf(vararg pairs: Pair<String, List<String>>): Parameters

Creates a parameters instance from the specified pairs

Creates a parameters instance from the entries of the given map

fun parametersOf(name: String, value: String): Parameters

Creates a parameters instance containing only single pair

fun parametersOf(name: String, values: List<String>): Parameters

Creates a parameters instance containing only single pair of name with multiple values

Link copied to clipboard

Parse Content-Type header values and sort them by quality and asterisks quantity

Link copied to clipboard

Parse header value and sort multiple values according to qualities

Link copied to clipboard
fun parseClientCookiesHeader(cookiesHeader: String, skipEscaped: Boolean = true): Map<String, String>

Parse client's Cookie header value

Link copied to clipboard
fun parseHeaderValue(text: String?, parametersOnly: Boolean): List<HeaderValue>

Parse header value respecting multi-values

Link copied to clipboard
fun parseQueryString(query: String, startIndex: Int = 0, limit: Int = 1000, decode: Boolean = true): Parameters

Parse query string withing starting at the specified startIndex but up to limit pairs

Link copied to clipboard

Parse Range header value

Link copied to clipboard

Parse server's Set-Cookie header value

Link copied to clipboard
fun String.parseUrlEncodedParameters(defaultEncoding: Charset = Charsets.UTF_8, limit: Int = 1000): Parameters

Parse URL query parameters. Shouldn't be used for urlencoded forms because of + character.

Link copied to clipboard
fun URLBuilder.path(vararg path: String)

Replace components in the current encodedPath. The path components will be escaped, except / character.

Link copied to clipboard
Link copied to clipboard
operator fun Parameters.plus(other: Parameters): Parameters

Plus operator function that creates a new parameters instance from the original one concatenating with other

Link copied to clipboard

Escape string using double quotes

Link copied to clipboard

Format Cookie header value

Link copied to clipboard
fun renderSetCookieHeader(name: String, value: String, encoding: CookieEncoding = CookieEncoding.URI_ENCODING, maxAge: Int = 0, expires: GMTDate? = null, domain: String? = null, path: String? = null, secure: Boolean = false, httpOnly: Boolean = false, extensions: Map<String, String?> = emptyMap(), includeEncoding: Boolean = true): String

Format Set-Cookie header value

Link copied to clipboard
fun URLBuilder.set(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, block: URLBuilder.() -> Unit = {})

Sets the url parts using the specified scheme, host, port and path. Pass null to keep existing value in the URLBuilder.

Link copied to clipboard

Parse Set-Cookie header value.

Link copied to clipboard

Take components from another url builder

Take components from another url

Take url parts from urlString throws URLParserException

Take URI components from uri

Take URL components from url

Link copied to clipboard

Construct a list of HeaderValueParam from an iterable of pairs

Link copied to clipboard

Convert GMTDate to valid http date String

Link copied to clipboard
fun Url.toURI(): URI

Convert Url to URI

Link copied to clipboard
fun Url(builder: URLBuilder): Url

Construct Url from builder without building origin.

fun Url(urlString: String): Url

Construct Url from urlString.

fun Url(uri: URI): Url

Helper method that concisely creates a Url from a URI

Link copied to clipboard

Construct URLBuilder from builder.

Construct URLBuilder from url.

fun URLBuilder(urlString: String): URLBuilder

Construct URLBuilder from urlString.

Link copied to clipboard

Set User-Agent header value.

Link copied to clipboard

Parse Vary header value.

Link copied to clipboard

Creates a copy of this type with the added charset parameter with charset value.

Link copied to clipboard

Creates a copy of this type with the added charset parameter with charset value if ContentType is not ignored

Properties

Link copied to clipboard
Link copied to clipboard
const val DEFAULT_PORT: Int = 0

Select default port value from protocol.

Link copied to clipboard
Link copied to clipboard

Full encoded path with query string but without domain, port and schema

Link copied to clipboard

Host:port pair, not normalized so port is always specified even if the port is schema's default

Link copied to clipboard

Checks if Url has absolute path.

Checks if Url has absolute path.

Link copied to clipboard

Checks if Url has absolute path.

Checks if Url has absolute path.

Link copied to clipboard

Hostname of current origin.

Hostname of current origin.

Hostname of current origin.

Hostname of current origin.

Link copied to clipboard

A Url protocol and authority.