CtrlK
BlogDocsLog inGet started
Tessl Logo

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.

Pending
Overview
Eval results
Files

http-methods-status.mddocs/

HTTP Methods and Status Codes

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

Capabilities

HTTP Method

Represents HTTP methods/verbs with predefined constants for all standard methods.

/**
 * Represents an HTTP method/verb
 * @param value the method name (e.g., "GET", "POST")
 */
data class HttpMethod(val value: String) {
    companion object {
        /** GET method for retrieving data */
        val Get: HttpMethod
        
        /** POST method for creating resources */
        val Post: HttpMethod
        
        /** PUT method for updating/creating resources */
        val Put: HttpMethod
        
        /** PATCH method for partial updates */
        val Patch: HttpMethod
        
        /** DELETE method for removing resources */
        val Delete: HttpMethod
        
        /** HEAD method for retrieving headers only */
        val Head: HttpMethod
        
        /** OPTIONS method for checking available methods */
        val Options: HttpMethod
        
        /** List of all default HTTP methods */
        val DefaultMethods: List<HttpMethod>
        
        /**
         * Parse HTTP method from string
         * @param method the method name string
         * @return HttpMethod instance
         */
        fun parse(method: String): HttpMethod
    }
}

Usage Examples:

import io.ktor.http.*

// Use predefined methods
val getMethod = HttpMethod.Get
val postMethod = HttpMethod.Post

// Parse custom method
val customMethod = HttpMethod.parse("CUSTOM")

// Check method value
println(getMethod.value) // "GET"

HTTP Status Code

Represents HTTP status codes with descriptions and utility functions for checking status categories.

/**
 * Represents an HTTP status code with description
 * @param value the numeric status code (e.g., 200, 404)
 * @param description human-readable description
 */
data class HttpStatusCode(val value: Int, val description: String) {
    /**
     * Create a copy with a new description
     * @param value new description text
     * @return new HttpStatusCode with updated description
     */
    fun description(value: String): HttpStatusCode
    
    /**
     * Compare status codes by numeric value
     * @param other status code to compare with
     * @return comparison result
     */
    fun compareTo(other: HttpStatusCode): Int
    
    companion object {
        // 1xx Informational
        /** 100 Continue */
        val Continue: HttpStatusCode
        
        /** 101 Switching Protocols */
        val SwitchingProtocols: HttpStatusCode
        
        /** 102 Processing */
        val Processing: HttpStatusCode
        
        // 2xx Success
        /** 200 OK */
        val OK: HttpStatusCode
        
        /** 201 Created */
        val Created: HttpStatusCode
        
        /** 202 Accepted */
        val Accepted: HttpStatusCode
        
        /** 203 Non-Authoritative Information */
        val NonAuthoritativeInformation: HttpStatusCode
        
        /** 204 No Content */
        val NoContent: HttpStatusCode
        
        /** 205 Reset Content */
        val ResetContent: HttpStatusCode
        
        /** 206 Partial Content */
        val PartialContent: HttpStatusCode
        
        /** 207 Multi-Status */
        val MultiStatus: HttpStatusCode
        
        // 3xx Redirection
        /** 300 Multiple Choices */
        val MultipleChoices: HttpStatusCode
        
        /** 301 Moved Permanently */
        val MovedPermanently: HttpStatusCode
        
        /** 302 Found */
        val Found: HttpStatusCode
        
        /** 303 See Other */
        val SeeOther: HttpStatusCode
        
        /** 304 Not Modified */
        val NotModified: HttpStatusCode
        
        /** 305 Use Proxy */
        val UseProxy: HttpStatusCode
        
        /** 306 Switch Proxy */
        val SwitchProxy: HttpStatusCode
        
        /** 307 Temporary Redirect */
        val TemporaryRedirect: HttpStatusCode
        
        /** 308 Permanent Redirect */
        val PermanentRedirect: HttpStatusCode
        
        // 4xx Client Error
        /** 400 Bad Request */
        val BadRequest: HttpStatusCode
        
        /** 401 Unauthorized */
        val Unauthorized: HttpStatusCode
        
        /** 402 Payment Required */
        val PaymentRequired: HttpStatusCode
        
        /** 403 Forbidden */
        val Forbidden: HttpStatusCode
        
        /** 404 Not Found */
        val NotFound: HttpStatusCode
        
        /** 405 Method Not Allowed */
        val MethodNotAllowed: HttpStatusCode
        
        /** 406 Not Acceptable */
        val NotAcceptable: HttpStatusCode
        
        /** 407 Proxy Authentication Required */
        val ProxyAuthenticationRequired: HttpStatusCode
        
        /** 408 Request Timeout */
        val RequestTimeout: HttpStatusCode
        
        /** 409 Conflict */
        val Conflict: HttpStatusCode
        
        /** 410 Gone */
        val Gone: HttpStatusCode
        
        /** 411 Length Required */
        val LengthRequired: HttpStatusCode
        
        /** 412 Precondition Failed */
        val PreconditionFailed: HttpStatusCode
        
        /** 413 Payload Too Large */
        val PayloadTooLarge: HttpStatusCode
        
        /** 414 Request-URI Too Long */
        val RequestURITooLong: HttpStatusCode
        
        /** 415 Unsupported Media Type */
        val UnsupportedMediaType: HttpStatusCode
        
        /** 416 Requested Range Not Satisfiable */
        val RequestedRangeNotSatisfiable: HttpStatusCode
        
        /** 417 Expectation Failed */
        val ExpectationFailed: HttpStatusCode
        
        /** 422 Unprocessable Entity */
        val UnprocessableEntity: HttpStatusCode
        
        /** 423 Locked */
        val Locked: HttpStatusCode
        
        /** 424 Failed Dependency */
        val FailedDependency: HttpStatusCode
        
        /** 425 Too Early */
        val TooEarly: HttpStatusCode
        
        /** 426 Upgrade Required */
        val UpgradeRequired: HttpStatusCode
        
        /** 429 Too Many Requests */
        val TooManyRequests: HttpStatusCode
        
        /** 431 Request Header Fields Too Large */
        val RequestHeaderFieldTooLarge: HttpStatusCode
        
        // 5xx Server Error
        /** 500 Internal Server Error */
        val InternalServerError: HttpStatusCode
        
        /** 501 Not Implemented */
        val NotImplemented: HttpStatusCode
        
        /** 502 Bad Gateway */
        val BadGateway: HttpStatusCode
        
        /** 503 Service Unavailable */
        val ServiceUnavailable: HttpStatusCode
        
        /** 504 Gateway Timeout */
        val GatewayTimeout: HttpStatusCode
        
        /** 505 HTTP Version Not Supported */
        val VersionNotSupported: HttpStatusCode
        
        /** 506 Variant Also Negotiates */
        val VariantAlsoNegotiates: HttpStatusCode
        
        /** 507 Insufficient Storage */
        val InsufficientStorage: HttpStatusCode
        
        /** List of all predefined status codes */
        val allStatusCodes: List<HttpStatusCode>
        
        /**
         * Create status code from numeric value
         * @param value the numeric status code
         * @return HttpStatusCode instance with default description
         */
        fun fromValue(value: Int): HttpStatusCode
    }
}

Status Code Utilities

Extension functions for checking status code categories.

/**
 * Check if status code indicates success (2xx range)
 * @return true if status code is in 200-299 range
 */
fun HttpStatusCode.isSuccess(): Boolean

Usage Examples:

import io.ktor.http.*

// Use predefined status codes
val okStatus = HttpStatusCode.OK
val notFoundStatus = HttpStatusCode.NotFound

// Check status properties
println(okStatus.value) // 200
println(okStatus.description) // "OK"
println(okStatus.isSuccess()) // true
println(notFoundStatus.isSuccess()) // false

// Create custom status code
val customStatus = HttpStatusCode.fromValue(418)
println(customStatus.description) // Default description for 418

// Create with custom description
val teapotStatus = customStatus.description("I'm a teapot")
println(teapotStatus.description) // "I'm a teapot"

// Compare status codes
val comparison = HttpStatusCode.OK.compareTo(HttpStatusCode.NotFound)
println(comparison < 0) // true (200 < 404)

// Access all available status codes
HttpStatusCode.allStatusCodes.forEach { status ->
    println("${status.value}: ${status.description}")
}

Types

// No additional types - HttpMethod and HttpStatusCode are self-contained

Install with Tessl CLI

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

docs

authentication.md

content-processing.md

content-types.md

cookies.md

date-utilities.md

header-parsing.md

headers.md

http-message-extensions.md

http-methods-status.md

index.md

multipart.md

parameters.md

url-encoding.md

url-handling.md

tile.json