This commit is contained in:
silva guimaraes 2025-07-13 13:45:10 -03:00
parent 86f8051e3b
commit 64368b1651
2 changed files with 29 additions and 15 deletions

View file

@ -20,7 +20,8 @@ let update_page content =
Cohttp_lwt.Body.of_form
[
("csrfmiddlewaretoken", [ value ]);
("edit_code", [ "foo perro bar caca" ]); (* TODO: use environmental variables *)
(* TODO: use environmental variables *)
("edit_code", [ "foo perro bar caca" ]);
("metadata", [ "ACCESS_RECOMMENDED_THEME=dark" ]);
("text", [ content ]);
]
@ -28,10 +29,6 @@ let update_page content =
let uri = Uri.of_string "https://rentry.org/copalib-schedule/edit" in
let req_headers =
Cohttp.Header.(
let h0 = init () in
let h1 = add h0 "Referer" "https://rentry.org" in
let h2 = add h1 "Content-Type" "application/x-www-form-urlencoded" in
let h3 = add h2 "User-Agent" "copabot/0.1.0" in
let hname, hvalue =
cookies
|> List.map (fun (x : string * Cookie.Set_cookie_hdr.t) ->
@ -39,7 +36,17 @@ let update_page content =
v.cookie)
|> Cookie.Cookie_hdr.serialize
in
add h3 hname hvalue)
let rec aux h = function
| [] -> h
| (k, v) :: tail -> aux (add h k v) tail
in
aux (init ())
[
("Referer", "https://rentry.org");
("Content-Type", "application/x-www-form-urlencoded");
( "User-Agent", "copabot/0.1.0" );
(hname, hvalue);
])
in
let* resp, _ =
Cohttp_lwt_unix.Client.post uri ?body:(Some form)