URL: https://linuxfr.org/forums/programmationautre/posts/envoyer-un-multipart-form-data-avec-ocaml-curl Title: Envoyer un multipart/form-data avec ocaml-curl Authors: Calve Date: 2013年10月23日T23:19:26+02:00 License: CC By-SA Tags: ocaml et curl Score: 1 Bonsoir ! J'écrit un petit programme pour envoyer mes TPs sur un serveur en ocaml, en utilisant ocurl, un wrapper pour libcurl. J'arrive à faire ce que je veux sans soucis en ligne de commande, mais pas avec ocurl Je veux vraisemblablement envoyé mon fichier en multipart/form-data Ma ligne ```bash curl -v "myhost/upload2.php" --form "fichier1= @file.tar.gz" --form "MAX_FILE_SIZE=1000000" -b cookie ``` Qui répond > POST /upload2.php HTTP/1.1 > User-Agent: curl/7.32.0 > Host: myhost > Accept: */* > Cookie: PHPSESSID=4qbihrkhode23902q1v988a114; cookie_test=1 > Content-Length: 10563 > Expect: 100-continue > Content-Type: multipart/form-data; boundary=------------------------53aa2e4a08d1f7c0 > < HTTP/1.1 100 Continue < HTTP/1.1 200 OK < Date: Wed, 23 Oct 2013 17:34:21 GMT * Server Apache/2.2.16 (Debian) is not blacklisted < Server: Apache/2.2.16 (Debian) < X-Powered-By: PHP/5.3.3-7+squeeze17 < Expires: Thu, 19 Nov 1981 08:52:00 GMT < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 < Pragma: no-cache < Vary: Accept-Encoding < Content-Length: 2265 < Content-Type: text/html < Mon ocaml ```ocaml let fetch connection url = Printf.printf "Retriving %s ...\n" (url); flush stdout; Curl.set_url connection url; Curl.perform connection; Curl.set_post connection false in let curl_file_option = Curl.CURLFORM_FILECONTENT("fichier1","unexisting.tar.gz",Curl.CONTENTTYPE "application/x-tar") in Curl.set_maxfilesize connection (Int32.of_int 1000000); Curl.set_httppost connection [curl_file_option]; fetch connection (baseURL^"upload2.php"); ``` Qui ne produit absolument rien sinon de manger 100% CPU Une idée ? un aiguillage ? Merci d'avance :)

AltStyle によって変換されたページ (->オリジナル) /