Compare commits

...

2 commits

Author SHA1 Message Date
Simon Cruanes
44a2b9f149
add custom method variant for extended HTTP methods
Some checks failed
format / format (push) Has been cancelled
github pages / deploy (push) Has been cancelled
build / Build (push) Has been cancelled
close #26
2026-02-09 17:26:41 -05:00
Christopher Zimmermann
1c489f0097 reset easy handle before use
One thing this does is reset the request method to the default, which
otherwise would be stuck at any request method previously set with
Curl.set_customrequest
2026-02-09 10:00:24 -05:00
2 changed files with 10 additions and 2 deletions

View file

@ -203,6 +203,7 @@ type meth =
| OPTIONS
| TRACE
| PATCH
| HTTP_CUSTOM of string
let string_of_meth = function
| GET -> "GET"
@ -214,6 +215,7 @@ let string_of_meth = function
| OPTIONS -> "OPTIONS"
| TRACE -> "TRACE"
| PATCH -> "PATCH"
| HTTP_CUSTOM s -> s
let pp_meth out m = Format.pp_print_string out (string_of_meth m)
@ -399,7 +401,9 @@ module Make (IO : IO) : S with type 'a io = 'a IO.t = struct
let do_cleanup, self =
match client with
| None -> true, make ()
| Some c -> false, c
| Some c ->
Curl.reset c.curl;
false, c
in
_apply_config self config;
opt_iter range ~f:(fun s -> Curl.set_range self.curl s);
@ -440,7 +444,10 @@ module Make (IO : IO) : S with type 'a io = 'a IO.t = struct
| HEAD -> Curl.set_customrequest self.curl "HEAD"
| CONNECT -> Curl.set_customrequest self.curl "CONNECT"
| OPTIONS -> Curl.set_customrequest self.curl "OPTIONS"
| TRACE -> Curl.set_customrequest self.curl "TRACE");
| TRACE -> Curl.set_customrequest self.curl "TRACE"
| HTTP_CUSTOM s ->
Curl.set_customrequest self.curl s;
if content <> None then Curl.set_upload self.curl true);
_set_headers self !headers;
Curl.set_headerfunction self.curl (fun s0 ->

View file

@ -114,6 +114,7 @@ type meth =
| OPTIONS
| TRACE
| PATCH
| HTTP_CUSTOM of string (** Custom HTTP method (e.g., for WebDAV) *)
val pp_meth : Format.formatter -> meth -> unit
val string_of_meth : meth -> string