mirror of
https://github.com/c-cube/ezcurl.git
synced 2026-03-07 21:47:55 -05:00
Refactor: group PUT and PATCH together with conditional upload
Both methods need identical handling (customrequest + upload flag), so combine them using pattern matching to reduce duplication. Only set the upload flag when content is provided, matching the behavior of POST and preventing curl from trying to read when there's no content to upload.
This commit is contained in:
parent
6662364103
commit
aec132d37c
1 changed files with 4 additions and 7 deletions
|
|
@ -434,17 +434,14 @@ module Make (IO : IO) : S with type 'a io = 'a IO.t = struct
|
||||||
| POST [] when content <> None -> Curl.set_post self.curl true
|
| POST [] when content <> None -> Curl.set_post self.curl true
|
||||||
| POST l -> Curl.set_httppost self.curl l
|
| POST l -> Curl.set_httppost self.curl l
|
||||||
| GET -> Curl.set_httpget self.curl true
|
| GET -> Curl.set_httpget self.curl true
|
||||||
| PUT ->
|
| (PUT | PATCH) as meth ->
|
||||||
Curl.set_customrequest self.curl "PUT";
|
Curl.set_customrequest self.curl (string_of_meth meth);
|
||||||
Curl.set_upload self.curl true
|
if content <> None then Curl.set_upload self.curl true
|
||||||
| DELETE -> Curl.set_customrequest self.curl "DELETE"
|
| DELETE -> Curl.set_customrequest self.curl "DELETE"
|
||||||
| HEAD -> Curl.set_customrequest self.curl "HEAD"
|
| HEAD -> Curl.set_customrequest self.curl "HEAD"
|
||||||
| CONNECT -> Curl.set_customrequest self.curl "CONNECT"
|
| CONNECT -> Curl.set_customrequest self.curl "CONNECT"
|
||||||
| OPTIONS -> Curl.set_customrequest self.curl "OPTIONS"
|
| OPTIONS -> Curl.set_customrequest self.curl "OPTIONS"
|
||||||
| TRACE -> Curl.set_customrequest self.curl "TRACE"
|
| TRACE -> Curl.set_customrequest self.curl "TRACE");
|
||||||
| PATCH ->
|
|
||||||
Curl.set_customrequest self.curl "PATCH";
|
|
||||||
Curl.set_upload self.curl true);
|
|
||||||
|
|
||||||
_set_headers self !headers;
|
_set_headers self !headers;
|
||||||
Curl.set_headerfunction self.curl (fun s0 ->
|
Curl.set_headerfunction self.curl (fun s0 ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue