14 HTTP
(require koyo/http) | package: koyo-lib |
This module provides utilities for working with HTTP-related data structures.
procedure
(request-headers-ref req header) → (or/c #f bytes?)
req : request? header : bytes?
Added in version 0.29 of package koyo-lib.
procedure
(request-headers-ref* req header) → (or/c #f string?)
req : request? header : bytes?
Added in version 0.29 of package koyo-lib.
procedure
(request-ip-address req) → string?
req : request?
Added in version 0.29 of package koyo-lib.
procedure
(request-json req) → jsexpr?
req : request?
Added in version 0.29 of package koyo-lib.
procedure
(request-path req) → string?
req : request?
procedure
(request-reroot req root) → (or/c #f request?)
req : request? root : url?
> (require koyo/http koyo/testing net/url web-server/http)
> (url->string (request-uri (request-reroot (make-test-request #:path "/a/b/c") (string->url "/a/b")))) "http://127.0.0.1:80/c"
> (request-reroot (make-test-request #:path "/d") (string->url "/a/b")) #f
Added in version 0.28 of package koyo-lib.
procedure
(bindings-ref bindings name [default]) → (or/c #f string?)
bindings : (listof binding?) name : symbol? default : (or/c #f string?) = #f
procedure
(bindings-ref-bytes bindings name [default]) → (or/c #f bytes?)
bindings : (listof binding?) name : symbol? default : (or/c #f bytes?) = #f
procedure
(bindings-ref-number bindings name [default]) → (or/c #f number?)
bindings : (listof binding?) name : symbol? default : (or/c #f number?) = #f
procedure
(bindings-ref-symbol bindings name [default]) → (or/c #f symbol?)
bindings : (listof binding?) name : symbol? default : (or/c #f symbol?) = #f
> (require koyo/http net/url)
> (url->string (url-scrub (string->url "https://127.0.0.1/foo/bar;(\"k\" . \"123\")/baz"))) "https://127.0.0.1/foo/bar/baz"
> (require koyo/http net/url) > (url-path* (string->url "https://example.com")) "/"
> (url-path* (string->url "https://example.com/")) "/"
> (url-path* (string->url "https://example.com/a/b/c")) "/a/b/c"
Added in version 0.21 of package koyo-lib.
procedure
(url-has-path? u p) → boolean?
u : url? p : string?
> (require koyo/http net/url) > (url-has-path? (string->url "https://example.com") "") #t
> (url-has-path? (string->url "https://example.com") "/") #t
> (url-has-path? (string->url "https://example.com/a") "/a") #t
> (url-has-path? (string->url "https://example.com/a/b/c") "/a/b/c") #t
> (url-has-path? (string->url "https://example.com/a/b/c") "a/b/c") #t
Added in version 0.21 of package koyo-lib.