URLBuilder

class URLBuilder(protocol: URLProtocol, host: String, port: Int, user: String?, password: String?, pathSegments: List<String>, parameters: Parameters, fragment: String, trailingQuery: Boolean)

A URL builder with all mutable components

Constructors

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

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun build(): Url

Build a Url instance (everything is copied to a new instance)

Link copied to clipboard
fun buildString(): String

Build a URL string

Properties

Link copied to clipboard
var encodedFragment: String
Link copied to clipboard
var encodedParameters: ParametersBuilder
Link copied to clipboard
var encodedPassword: String?
Link copied to clipboard
var encodedPathSegments: List<String>
Link copied to clipboard
var encodedUser: String?
Link copied to clipboard
var fragment: String

URL fragment (anchor name)

Link copied to clipboard
var host: String

name without port (domain)

Link copied to clipboard
var parameters: ParametersBuilder

URL query parameters

Link copied to clipboard
var password: String?

password part (optional)

Link copied to clipboard
var pathSegments: List<String>

URL path without query

Link copied to clipboard
var port: Int

port number

Link copied to clipboard
var protocol: URLProtocol

URL protocol (scheme)

Link copied to clipboard
var trailingQuery: Boolean = false

keep a trailing question character even if there are no query parameters

Link copied to clipboard
var user: String?

username part (optional)

Extensions

Link copied to clipboard
fun URLBuilder.appendEncodedPathSegments(segments: List<String>): URLBuilder

Adds components to current encodedPath

fun URLBuilder.appendEncodedPathSegments(vararg components: String): URLBuilder

Adds components to current encodedPath

Link copied to clipboard
fun URLBuilder.appendPathSegments(segments: List<String>): URLBuilder

Adds components to current encodedPath

fun URLBuilder.appendPathSegments(vararg components: String): URLBuilder

Adds components to current encodedPath

Link copied to clipboard
val URLBuilder.authority: String

URLBuilder authority.

Link copied to clipboard
fun URLBuilder.clone(): URLBuilder

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

Link copied to clipboard
var URLBuilder.encodedPath: String
Link copied to clipboard
fun URLBuilder.path(vararg path: String)
Link copied to clipboard
fun URLBuilder.pathComponents(vararg components: String): URLBuilder
fun URLBuilder.pathComponents(components: List<String>): URLBuilder
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
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