Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-httpclient

Named HTTP clients for Pudu: a client factory, delegating handlers, pooled keep-alive connections, handler lifetimes, logging, and resilience

0.1.1Apache-2.01

InstallClose

Version.pudu

Pudu20 lines798 B

GitHub ↗
1/** @Domain.Version.Module — the protocol version a request is sent with */2module PuduLangHttpClient.Domain.Version34import Std.Http as Http56/** @Domain.Version.Policy — how far the sent version may stray from the requested one */7export type Policy = OrLower | Exact | OrHigher89/// The version the transport sends for a requested version under a policy, or `None` when the10/// policy rules out every version the transport speaks: HTTP/1.0 and HTTP/1.1.11export fn negotiate(requested: &Http.Version, policy: &Policy) -> Option[Http.Version] {12  match (*requested, *policy) {13    case (Http.Http10, OrHigher) => Some(Http.Http11)14    case (Http.Http10, _) => Some(Http.Http10)15    case (Http.Http11, _) => Some(Http.Http11)16    case (_, OrLower) => Some(Http.Http11)17    case _ => None18  }19}20