or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdcontent-processing.mdcontent-types.mdcookies.mddate-utilities.mdheader-parsing.mdheaders.mdhttp-message-extensions.mdhttp-methods-status.mdindex.mdmultipart.mdparameters.mdurl-encoding.mdurl-handling.md
tile.json

tessl/kotlin-io-ktor--ktor-http-iosarm64

Ktor HTTP library for iOS ARM64 providing HTTP utilities, content types, headers manipulation, URL building, and HTTP message handling for iOS ARM64 applications built with Kotlin Multiplatform.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes

pkg:kotlin/io.ktor:ktor-http-iosarm64@2.3.x

To install, run

npx @tessl/cli install tessl/kotlin-io-ktor--ktor-http-iosarm64@2.3.0

index.mddocs/

Ktor HTTP Library for iOS ARM64

Ktor HTTP is a comprehensive HTTP utilities library for iOS ARM64 applications built with Kotlin Multiplatform. It provides essential HTTP functionality including methods, status codes, headers, URL handling, content types, authentication, cookies, and content processing. The library is designed for maximum cross-platform compatibility while offering native iOS ARM64 performance.

Package Information

  • Package Name: io.ktor:ktor-http-iosarm64
  • Package Type: kotlin/gradle
  • Language: Kotlin
  • Platform: iOS ARM64 (via Kotlin Multiplatform)
  • Installation: Add to your Kotlin Multiplatform project's build.gradle.kts
kotlin {
    iosArm64 {
        dependencies {
            implementation("io.ktor:ktor-http:2.3.13")
        }
    }
}

Core Imports

import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.http.auth.*

Basic Usage

import io.ktor.http.*

// Create HTTP method
val method = HttpMethod.Get

// Work with status codes
val status = HttpStatusCode.OK
println(status.isSuccess()) // true

// Build URLs
val url = URLBuilder("https://api.example.com")
    .appendPathSegments("users", "123")
    .parameters.append("format", "json")
    .build()

// Handle content types
val jsonType = ContentType.Application.Json
val textType = ContentType.Text.Plain.withCharset(Charsets.UTF_8)

// Work with headers
val headers = headersOf(
    HttpHeaders.Authorization to "Bearer token123",
    HttpHeaders.ContentType to ContentType.Application.Json.toString()
)

Architecture

The Ktor HTTP library is organized around several key functional areas:

  • Core HTTP Elements: Methods, status codes, protocol versions, and message interfaces
  • Headers Management: Type-safe header handling with validation and case-insensitive access
  • URL Processing: Immutable URLs and mutable builders for URL construction and manipulation
  • Content Handling: Content types, multipart processing, and outgoing content abstractions
  • Authentication: Support for multiple auth schemes with header parsing and challenge generation
  • Cookie Management: Complete cookie lifecycle with encoding options and security features
  • Parameter Processing: Query parameters and form data handling
  • Range Requests: HTTP range specification and content range handling

Capabilities

HTTP Methods and Status Codes

Core HTTP method constants and comprehensive status code definitions with success/error checking utilities.

data class HttpMethod(val value: String) {
    companion object {
        val Get: HttpMethod
        val Post: HttpMethod
        val Put: HttpMethod
        val Delete: HttpMethod
        // ... other standard methods
    }
}

data class HttpStatusCode(val value: Int, val description: String) {
    companion object {
        val OK: HttpStatusCode // 200
        val NotFound: HttpStatusCode // 404
        val InternalServerError: HttpStatusCode // 500
        // ... comprehensive status codes
    }
}

HTTP Methods and Status Codes

Headers Management

Type-safe HTTP header handling with constants for all standard headers, validation, and case-insensitive access.

object HttpHeaders {
    const val Authorization: String
    const val ContentType: String
    const val Accept: String
    // ... all standard headers
}

interface Headers : StringValues {
    companion object {
        val Empty: Headers
        fun build(builder: HeadersBuilder.() -> Unit): Headers
    }
}

Headers Management

URL Handling

Immutable URL representation and mutable builders for URL construction with protocol handling and parameter management.

class Url {
    val protocol: URLProtocol
    val host: String
    val port: Int  
    val pathSegments: List<String>
    val parameters: Parameters
    val fragment: String
}

class URLBuilder {
    var protocol: URLProtocol
    var host: String
    var port: Int
    val parameters: ParametersBuilder
    fun build(): Url
    fun appendPathSegments(vararg components: String): URLBuilder
}

URL Handling

Content Types and File Handling

Comprehensive content type definitions with MIME type constants and file extension mapping.

class ContentType(
    val contentType: String,
    val contentSubtype: String,
    val parameters: List<HeaderValueParam>
) {
    fun withParameter(name: String, value: String): ContentType
    fun match(pattern: ContentType): Boolean
    
    object Application {
        val Json: ContentType
        val OctetStream: ContentType
        val FormUrlEncoded: ContentType
        // ... comprehensive type definitions
    }
}

Content Types and File Handling

Content Processing

Outgoing content abstractions for different content types including streaming, byte arrays, and protocol upgrades.

sealed class OutgoingContent {
    abstract val contentType: ContentType?
    abstract val contentLength: Long?
    abstract val headers: Headers
    
    object NoContent : OutgoingContent
    abstract class ByteArrayContent : OutgoingContent
    abstract class WriteChannelContent : OutgoingContent
    abstract class ReadChannelContent : OutgoingContent
}

Content Processing

Multipart Handling

Multipart form data processing with support for form fields, file uploads, and binary data.

sealed class PartData(
    val dispose: () -> Unit,
    val headers: Headers
) {
    val contentDisposition: ContentDisposition?
    val name: String?
    
    class FormItem(val value: String, dispose: () -> Unit, partHeaders: Headers) : PartData
    class FileItem(val provider: () -> Input, dispose: () -> Unit, partHeaders: Headers) : PartData
}

interface MultiPartData {
    suspend fun readPart(): PartData?
}

Multipart Handling

Authentication

HTTP authentication support for multiple schemes including Basic, Bearer, Digest, and OAuth with header parsing.

object AuthScheme {
    const val Basic: String
    const val Bearer: String
    const val Digest: String
    const val OAuth: String
}

sealed class HttpAuthHeader(val authScheme: String) {
    class Single(authScheme: String, val blob: String) : HttpAuthHeader(authScheme)
    class Parameterized(
        authScheme: String,
        val parameters: List<HeaderValueParam>,
        val encoding: HeaderValueEncoding
    ) : HttpAuthHeader(authScheme)
}

Authentication

Cookie Management

Complete cookie handling with encoding options, security attributes, and parsing/rendering utilities.

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()
)

enum class CookieEncoding {
    RAW, DQUOTES, URI_ENCODING, BASE64_ENCODING
}

Cookie Management

Parameters and Query Handling

Query parameter and form data handling with case-insensitive access and builder patterns.

interface Parameters : StringValues {
    companion object {
        val Empty: Parameters
        fun build(builder: ParametersBuilder.() -> Unit): Parameters
    }
}

interface ParametersBuilder : StringValuesBuilder {
    fun build(): Parameters
}

Parameters and Query Handling

URL Encoding and Decoding

Comprehensive URL encoding and decoding functions for all URL components with support for query parameters, path segments, and OAuth encoding.

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

fun String.encodeURLPath(): String
fun String.encodeURLPathPart(): String
fun String.encodeURLParameter(spaceToPlus: Boolean = false): String
fun String.encodeOAuth(): String

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

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

class URLDecodeException(message: String) : Exception

URL Encoding and Decoding

HTTP Message Extensions

Extension functions for HTTP messages providing convenient access to common headers with automatic parsing and type-safe handling.

fun HttpMessageBuilder.contentType(type: ContentType): Unit
fun HttpMessageBuilder.contentType(): ContentType?
fun HttpMessageBuilder.charset(): Charset?
fun HttpMessageBuilder.userAgent(content: String): Unit
fun HttpMessageBuilder.maxAge(seconds: Int): Unit

fun HttpMessage.contentType(): ContentType?
fun HttpMessage.charset(): Charset?
fun HttpMessage.etag(): String?
fun HttpMessage.vary(): List<String>?
fun HttpMessage.contentLength(): Long?
fun HttpMessage.setCookie(): List<Cookie>
fun HttpMessage.cacheControl(): List<HeaderValue>

HTTP Message Extensions

Date Utilities

HTTP and cookie date parsing and formatting utilities with support for multiple date formats and GMT conversion.

fun String.fromHttpToGmtDate(): GMTDate
fun String.fromCookieToGmtDate(): GMTDate
fun GMTDate.toHttpDate(): String

Date Utilities

Header Value Parsing

Comprehensive header value parsing utilities for handling complex headers with parameters, quality values, and content negotiation.

data class HeaderValue(val value: String, val params: List<HeaderValueParam>) {
    val quality: Double
}

data class HeaderValueParam(val name: String, val value: String, val escapeValue: Boolean)

fun parseHeaderValue(text: String?): List<HeaderValue>
fun parseAndSortHeader(header: String?): List<HeaderValue>
fun parseAndSortContentTypeHeader(header: String?): List<HeaderValue>

Header Value Parsing

Types

data class URLProtocol(val name: String, val defaultPort: Int) {
    companion object {
        val HTTP: URLProtocol
        val HTTPS: URLProtocol
        val WS: URLProtocol
        val WSS: URLProtocol
    }
}

data class HttpProtocolVersion(val name: String, val major: Int, val minor: Int) {
    companion object {
        val HTTP_1_0: HttpProtocolVersion
        val HTTP_1_1: HttpProtocolVersion
        val HTTP_2_0: HttpProtocolVersion
    }
}

interface StringValues {
    val caseInsensitiveName: Boolean
    fun get(name: String): String?
    fun getAll(name: String): List<String>?
    fun contains(name: String): Boolean
    fun entries(): Set<Map.Entry<String, List<String>>>
    fun isEmpty(): Boolean
    fun names(): Set<String>
}

class HeaderValueParam(val name: String, val value: String)

class HeaderValueWithParameters(
    val content: String,
    val parameters: List<HeaderValueParam> = emptyList()
)