Sign in

    unmbt/http-server-mbt/core does not have a README file

    ConfigError

    pub(all) suberror ConfigError {
    InvalidBaseUrl(String)
    InvalidRoot(String)
    InvalidPort(String)
    InvalidTryFiles(String)
    ConflictingBaseUrl(String)
    ConflictingRouting(String)
    InvalidProxy(String)
    InvalidAuth(String)
    InvalidHeader(String)
    InvalidTimeout(String)
    InvalidTls(String)
    InvalidLimits(String)
    } derive(Eq,
    Debug
    )

    Configuration validation error hierarchy. All errors are detected and raised during pre-listen startup.
    impl Show for ConfigError

    ConfigError::equal

    fn ConfigError::equal(ConfigError, ConfigError) -> Bool

    ConfigError::not_equal

    fn ConfigError::not_equal(x : ConfigError, y : ConfigError) -> Bool

    ConfigError::output

    fn ConfigError::output(self : ConfigError, logger : &Logger) -> Unit

    ConfigError::to_string

    fn ConfigError::to_string(self : ConfigError) -> String

    PathError

    pub(all) suberror PathError {
    MalformedUri(String)
    OutsideBaseUrl(String)
    TraversalForbidden(String)
    NotFound(String)
    } derive(Eq,
    Debug
    )

    Errors resulting from path resolution and traversal defense.

    PathError::equal

    fn PathError::equal(PathError, PathError) -> Bool

    PathError::not_equal

    fn PathError::not_equal(x : PathError, y : PathError) -> Bool

    ByteRange

    pub(all) struct ByteRange {
    start : Int64
    end : Int64
    } derive(Eq,
    Debug
    )

    A response body range, inclusive at both ends.

    ByteRange::equal

    fn ByteRange::equal(ByteRange, ByteRange) -> Bool

    ByteRange::not_equal

    fn ByteRange::not_equal(x : ByteRange, y : ByteRange) -> Bool

    CachePolicy

    pub(all) enum CachePolicy {
    MaxAge(Int)
    NoCache
    Exact(String)
    } derive(Eq,
    Debug
    )

    Cache-Control header strategy.

    CachePolicy::equal

    fn CachePolicy::equal(CachePolicy, CachePolicy) -> Bool

    CachePolicy::not_equal

    fn CachePolicy::not_equal(x : CachePolicy, y : CachePolicy) -> Bool

    Config

    pub(all) struct Config {
    limits : RuntimeLimits
    root : String
    port : Int
    address : String
    base_url : String
    default_ext : String?
    spa : Bool
    try_files : String?
    gzip : Bool
    brotli : Bool
    force_content_encoding : Bool
    auto_index : Bool
    show_dir : Bool
    show_dotfiles : Bool
    dir_overrides_404 : Bool
    cache_seconds : Int
    cache_control : String?
    weak_etags : Bool
    weak_compare : Bool
    cors : Bool
    cors_headers : String?
    coop : Bool
    coop_header : String?
    pna : Bool
    basic_auth : (String, String)?
    host_whitelist : Array[String]
    custom_headers : Map[String, String]
    robots : Bool
    proxy : String?
    proxy_all : String?
    proxy_options : Map[String, String]
    websocket : Bool
    proxy_config : String?
    cert_file : String?
    key_file : String?
    key_passphrase : String?
    ca_file : String?
    secure : Bool
    handle_error : Bool
    idle_timeout_ms : Int
    mime_types : Map[String, String]
    log_ip : Bool
    silent : Bool
    } derive(
    Debug
    )

    Normalized static-server configuration model. Contains all configuration settings for protocol, static resolution, routing mounts, SPA fallback, security policies, and upstream proxies.

    Config::default

    fn Config::default(root : String) -> Config

    Build Server & CLI defaults for a filesystem root directory.

    Config::effective_cache_control

    fn Config::effective_cache_control(self : Config) -> String

    Returns the effective Cache-Control header string.

    Config::fallback_mode

    fn Config::fallback_mode(self : Config) -> FallbackMode

    Determine active page fallback mode.

    Config::fallback_target_file

    fn Config::fallback_target_file(self : Config) -> String?

    Returns the relative file path to serve on fallback, if enabled.

    Config::has_fallback

    fn Config::has_fallback(self : Config) -> Bool

    Returns whether any fallback mode is enabled.

    Config::has_proxy

    fn Config::has_proxy(self : Config) -> Bool

    Returns whether any upstream proxy mode is configured.

    Config::has_tls

    fn Config::has_tls(self : Config) -> Bool

    Returns whether TLS serving is enabled (D-01: disabled by default).

    Config::has_websocket_proxy

    fn Config::has_websocket_proxy(self : Config) -> Bool

    Returns whether WebSocket proxy capability is enabled.

    Config::middleware_default

    fn Config::middleware_default(root : String) -> Config

    Build Core Middleware defaults for a filesystem root directory (AD-02 compatibility).

    Config::proxy_targets_include_https

    fn Config::proxy_targets_include_https(self : Config) -> Bool

    Return whether configured upstream targets may require a TLS client. Inline/file proxy rules are conservatively treated as HTTPS when their configuration contains an https:// target.

    Config::to_repr

    Config::validate

    fn Config::validate(self : Config) -> Unit raise ConfigError

    Method syntax for validating a Config instance.

    EntityTag

    pub(all) struct EntityTag {
    tag : String
    is_weak : Bool
    } derive(Eq,
    Debug
    )

    An HTTP Entity Tag (RFC 7232 §2.3).

    EntityTag::equal

    fn EntityTag::equal(EntityTag, EntityTag) -> Bool

    EntityTag::from_metadata

    fn EntityTag::from_metadata(size : Int64, mtime_sec : Int64, weak : Bool) -> EntityTag

    Generate an EntityTag from file metadata (size and modification time in seconds).

    EntityTag::new

    fn EntityTag::new(raw_tag : String, weak : Bool) -> EntityTag

    Construct an EntityTag from a raw tag string and weak flag.

    EntityTag::not_equal

    fn EntityTag::not_equal(x : EntityTag, y : EntityTag) -> Bool

    EntityTag::parse

    fn EntityTag::parse(raw : String) -> EntityTag?

    Parse an EntityTag from a header string.

    EntityTag::to_header_value

    fn EntityTag::to_header_value(self : EntityTag) -> String

    Format EntityTag as an HTTP header value (e.g. ""123-456"" or "W/"123-456"").

    FallbackMode

    pub(all) enum FallbackMode {
    None
    Spa
    TryFiles(String)
    } derive(Eq,
    Debug
    )

    Active fallback mode for unrouted requests.

    FallbackMode::equal

    FallbackMode::not_equal

    fn FallbackMode::not_equal(x : FallbackMode, y : FallbackMode) -> Bool

    Method

    pub(all) enum Method {
    Get
    Head
    Other(String)
    } derive(Eq,
    Debug
    )

    HTTP methods supported by the static engine.

    Method::equal

    fn Method::equal(Method, Method) -> Bool

    Method::not_equal

    fn Method::not_equal(x : Method, y : Method) -> Bool

    Method::to_repr

    MimeRegistry

    pub(all) struct MimeRegistry {
    table : Map[String, String]
    }

    A registry mapping file extensions to MIME content types.

    MimeRegistry::lookup

    fn MimeRegistry::lookup(self : MimeRegistry, path_or_ext : String, default_type? : String) -> String

    Lookup MIME type for a given path or extension, falling back to default_type.

    MimeRegistry::new

    Create a new MimeRegistry initialized with the standard static web asset table.

    MimeRegistry::register

    fn MimeRegistry::register(self : MimeRegistry, ext : String, mime_type : String) -> Unit

    Alias for set to register an extension mapping.

    MimeRegistry::set

    fn MimeRegistry::set(self : MimeRegistry, ext : String, mime_type : String) -> Unit

    Register a custom extension mapping (e.g. "opml" -> "application/xml"). Strips leading dot and lowercases extension.

    MimeRegistry::set_all

    fn MimeRegistry::set_all(self : MimeRegistry, overrides : Map[String, String]) -> Unit

    Register multiple custom mappings from a map.

    ProxyRule

    pub(all) struct ProxyRule {
    pattern : String
    target : String
    path_rewrite : Array[(String, String)]
    } derive(Eq,
    Debug
    )

    A route-based proxy rule.

    ProxyRule::equal

    fn ProxyRule::equal(ProxyRule, ProxyRule) -> Bool

    ProxyRule::not_equal

    fn ProxyRule::not_equal(x : ProxyRule, y : ProxyRule) -> Bool

    RangeResult

    pub(all) enum RangeResult {
    Satisfiable(ByteRange)
    NotSatisfiable
    NotApplicable
    } derive(Eq,
    Debug
    )

    Result of evaluating an HTTP Range request.

    RangeResult::equal

    fn RangeResult::equal(RangeResult, RangeResult) -> Bool

    RangeResult::not_equal

    fn RangeResult::not_equal(x : RangeResult, y : RangeResult) -> Bool

    Request

    pub(all) struct Request {
    meth : Method
    target : String
    headers : Map[String, String]
    }

    A parsed HTTP request used by the static engine.

    ResponseBody

    pub(all) enum ResponseBody {
    Empty
    Bytes(Bytes)
    FileRegion(String, Int64, Int64)
    } derive(Eq,
    Debug
    )

    Representation of an HTTP response body.

    ResponseBody::equal

    ResponseBody::length

    fn ResponseBody::length(self : ResponseBody) -> Int

    Return the total byte length of the response body.

    ResponseBody::not_equal

    fn ResponseBody::not_equal(x : ResponseBody, y : ResponseBody) -> Bool

    RuntimeLimits

    pub(all) struct RuntimeLimits {
    file_workers : Int
    queued_operations : Int
    connections : Int
    body_block_bytes : Int
    body_buffer_bytes : Int
    directory_metadata_bytes : Int
    } derive(Eq,
    Debug
    )

    D-05/D-06: finite Native resources. Budgets include all instances sharing an owner.

    RuntimeLimits::default

    fn RuntimeLimits::default() -> RuntimeLimits

    RuntimeLimits::equal

    RuntimeLimits::not_equal

    fn RuntimeLimits::not_equal(x : RuntimeLimits, y : RuntimeLimits) -> Bool

    RuntimeLimits::validate

    fn RuntimeLimits::validate(self : RuntimeLimits) -> Unit raise ConfigError

    SecurityDecision

    pub(all) enum SecurityDecision {
    Proceed
    Unauthorized(Map[String, String], Bytes)
    Forbidden(Map[String, String], Bytes)
    Preflight(Map[String, String])
    } derive(
    Debug
    )

    Result of preliminary security policy evaluation.

    apply_default_ext

    fn apply_default_ext(path : String, default_ext : String) -> String

    Append default extension to an extensionless path.

    apply_security_headers

    fn apply_security_headers(headers : Map[String, String], config : Config, meth : Method) -> Unit

    Apply configured security headers (CORS, COOP, PNA, custom headers) to response.

    base64_decode_string

    fn base64_decode_string(input : StringView) -> String?

    Decode Base64 string to a UTF-8 string. Pure, portable implementation.

    check_host_allowed

    fn check_host_allowed(host_header : String?, allowed_hosts : Array[String]) -> Bool

    Check if request Host header is allowed by the whitelist.

    crypto_equals

    fn crypto_equals(expected : String, actual : String) -> Bool

    Constant-time string comparison preventing timing side-channel attacks. Loop duration depends strictly on expected.length().

    decode_percent

    fn decode_percent(value : StringView) -> String raise PathError

    Percent-decode a string or slice exactly once, decoding UTF-8 byte sequences.

    etag_matches

    fn etag_matches(client_raw : String, server_tag : EntityTag, weak_compare : Bool) -> Bool

    Compare a client-supplied raw ETag against the server's EntityTag.

    evaluate_security_policies

    fn evaluate_security_policies(config : Config, req : Request) -> SecurityDecision

    Execute security policies in the documented priority order: Host Whitelist -> Basic Auth -> OPTIONS Preflight.

    extract_extension

    fn extract_extension(path_or_filename : String) -> String

    Extract file extension from a path, filename, or bare extension string.

    extract_hostname

    fn extract_hostname(host_value : String) -> String

    Extract hostname from a Host header value by stripping port.

    find_header_case_insensitive

    fn find_header_case_insensitive(headers : Map[String, String], name : String) -> String?

    Find header in headers map case-insensitively.

    format_cache_control

    fn format_cache_control(policy : CachePolicy) -> String

    Format CachePolicy to header string value.

    format_content_range

    fn format_content_range(start : Int64, end : Int64, total : Int64) -> String

    Format Content-Range header for a successful 206 response. e.g. "bytes 3-5/11"

    format_content_range_unsatisfiable

    fn format_content_range_unsatisfiable(total : Int64) -> String

    Format Content-Range header for an unsatisfiable 416 response. e.g. "bytes */11" (per C004.03)

    format_dir_redirect

    fn format_dir_redirect(raw_path : String, raw_query : String?) -> String

    Formats the Location header for a directory 302 redirect, ensuring trailing slash is added before query and base_url is preserved.

    format_http_date

    fn format_http_date(epoch_sec : Int64) -> String

    Pure HTTP date formatter generating RFC 7231 IMF-fixdate: "Sun, 06 Nov 1994 08:49:37 GMT"

    has_file_extension

    fn has_file_extension(path : String) -> Bool

    Check if the path's filename component has an extension.

    if_none_match_matches

    fn if_none_match_matches(header_val : String, server_tag : EntityTag, weak_compare : Bool) -> Bool

    Check if an If-None-Match header value matches the server ETag.

    is_text_mime

    fn is_text_mime(mime : String) -> Bool

    Determine if a MIME content-type is text-based requiring charset decoration.

    match_and_strip_base_url

    fn match_and_strip_base_url(base_url : String, decoded_path : String) -> String?

    Match a decoded request path against the normalized base_url using strict component boundary matching. Returns Some(relative_path) on match, or None if the request falls outside the base_url mount.

    match_glob_path

    fn match_glob_path(pattern : String, path : String) -> Bool

    Check if a request path matches a glob or prefix pattern.

    match_proxy_rule

    fn match_proxy_rule(rule : ProxyRule, path : String) -> (String, String)?

    Match a URL path against a proxy rule and apply path rewriting. Returns Some((target, rewritten_path)) if matched, None otherwise.

    normalize_base_url

    fn normalize_base_url(value : String) -> String raise ConfigError

    Normalize a URL mount prefix per D-04.

    normalize_charset

    fn normalize_charset(raw : String) -> String

    Normalize charset label to WHATWG canonical format.

    normalize_extension

    fn normalize_extension(raw : String) -> String

    Normalize an extension string: strips leading dots and converts to lowercase.

    parse_auth_credential

    fn parse_auth_credential(str : String) -> (String, String)?

    Helper to parse CLI basic auth credentials in format "username:password".

    parse_basic_auth_header

    fn parse_basic_auth_header(header : String) -> (String, String)?

    Parse an HTTP Authorization header value: Basic <base64>.

    parse_http_date

    fn parse_http_date(date_str : String) -> Int64?

    Parse an HTTP date string into UTC epoch seconds. Supports IMF-fixdate ("Sun, 06 Nov 1994 08:49:37 GMT"), RFC 850 ("Sunday, 06-Nov-94 08:49:37 GMT"), asctime ("Sun Nov 6 08:49:37 1994"), and JS toString() ("Fri Sep 11 2026 15:20:00 GMT+0800"). Safely returns None on illegal / overflow dates (e.g. C003 "275760-09-24").

    parse_range

    fn parse_range(value : String, size : Int64) -> ByteRange?

    Legacy compatibility helper matching original core.parse_range.

    parse_range_spec

    fn parse_range_spec(header_val : String, total : Int64) -> RangeResult

    Parse an HTTP Range header string according to RFC 7233 and ecstatic compatibility.

    parse_types

    fn parse_types(content : String) -> Map[String, String]

    Parse Apache .types format file content into an extension -> mime_type Map.

    resolve_base_url

    fn resolve_base_url(base_url : String?, base_dir : String?) -> String raise ConfigError

    Resolve base_url and base_dir aliases.

    resolve_content_type

    fn resolve_content_type(path : String, registry : MimeRegistry, default_type : String, sample_bytes? : Bytes) -> String

    Formulate full Content-Type header with appropriate charset.

    resolve_path

    fn resolve_path(root : String, base_url : String, req_target : String) -> Result[String, PathError]

    Pure path resolution with root anchoring and BaseURL prefix matching.

    should_return_304

    fn should_return_304(if_none_match : String?, if_modified_since : String?, server_mtime_sec : Int64, server_etag : EntityTag, weak_compare : Bool) -> Bool

    Determine if a request satisfies cache conditions to return 304 Not Modified.

    sniff_html_charset

    fn sniff_html_charset(bytes : Bytes) -> String?

    Sniff character encoding from the first <= 1024 bytes of an HTML document.

    validate_config

    fn validate_config(config : Config) -> Unit raise ConfigError

    Validate all configuration settings before creating any network listener. Raises ConfigError on any syntactic defect or mutual exclusion conflict.

    validate_proxy_url

    fn validate_proxy_url(url : String) -> Unit raise ConfigError

    Validate upstream proxy URL format (http:// or https:// with valid host/port).

    validate_relative_path

    fn validate_relative_path(path : String) -> Bool

    Validate a user supplied root-relative path. Cleanly permits "" (representing the root directory itself).

    validate_root

    fn validate_root(root : String) -> String raise ConfigError

    Validate a filesystem root directory path.

    validate_tls

    fn validate_tls(config : Config) -> Unit raise ConfigError

    Validate TLS configuration pairing: enabling TLS requires both a certificate and a key (D-01). File readability and key/cert matching are verified during server startup preflight when the acceptor is built, before the listener is created.

    validate_try_files_path

    fn validate_try_files_path(path : String) -> String raise ConfigError

    Validate a user-specified try_files relative path.

    validate_uri_encoding

    fn validate_uri_encoding(target : String) -> Bool

    Validate percent encoding syntax across the entire target string. Ensures malformed percent escapes like /% or /?% are rejected with 400.

    verify_basic_auth

    fn verify_basic_auth(header : String?, expected : (String, String)) -> Bool

    Verify Basic Auth credentials with timing attack safety and dummy fallbacks.