HTTP types: headers, status codes, methods, bodies, MIME types
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-http: extend MDX to lib/header_name.mli

Add header_name.mli to the (mdx ...) stanza. The example was a
sketch with [print_endline] / [()] noise. Replaced with three
concrete asserts that confirm Headers.set + Headers.find round-trip
through the polymorphic-variant API for both standard headers and
[`Other "X-Custom-Header"].

+12 -12
+2 -1
lib/dune
··· 19 19 huri.mli 20 20 expect_continue.mli 21 21 cache_control.mli 22 - http_version.mli) 22 + http_version.mli 23 + header_name.mli) 23 24 (libraries nox-http requests uri eio eio.core eio.unix eio_main))
+10 -11
lib/header_name.mli
··· 12 12 {2 Usage} 13 13 14 14 {[ 15 - (* Use standard headers directly *) 16 - let headers = Headers.empty 17 - |> Headers.set `Content_type "application/json" 18 - |> Headers.set `Accept "text/html" 15 + open Http 19 16 20 - (* Use custom headers with `Other *) 21 - let headers = headers 22 - |> Headers.set (`Other "X-Custom-Header") "value" 17 + let headers = 18 + Headers.empty 19 + |> Headers.set `Content_type "application/json" 20 + |> Headers.set `Accept "text/html" 21 + |> Headers.set (`Other "X-Custom-Header") "value" 23 22 24 - (* Pattern match on headers *) 25 - match Headers.find `Content_type headers with 26 - | Some ct -> print_endline ct 27 - | None -> () 23 + let () = 24 + assert (Headers.find `Content_type headers = Some "application/json"); 25 + assert (Headers.find `Accept headers = Some "text/html"); 26 + assert (Headers.find (`Other "X-Custom-Header") headers = Some "value") 28 27 ]} 29 28 30 29 Header names are case-insensitive per