:PROPERTIES: :ID: 5ea61eaa-7f37-464c-aa69-8251de8f81af :mtime: 20220130135414 :ctime: 20220130133727 :END: #+title: curl * Introduction * Abréviation de Client URL Request Library, * Librairie écrite en C (/libcurl/) et une Interface en ligne de commande, * Destinée à récupérer le contenu d'une ressource (désignée à l'aide d'une URL) accessible via un réseau. * Permet de créer ou modifier une ressource (contrairement à wget), il peut ainsi être utilisé en tant que client REST, * Nombreux bindings (C++, Java, .NET, Perl, PHP, Ruby...), * Supporte (/libcurl/) les protocoles DICT, file, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet et TFTP. * Installation #+BEGIN_SRC shell sudo apt-get install curl #+END_SRC * Tips ** Obtenir l'en-tête HTTP d'une URL: #+BEGIN_SRC shell :output dispay curl -I git.adrien.run #+END_SRC #+RESULTS: | HTTP/1.1 | 301 | Moved | Permanently | | | | | Server: | nginx/1.18.0 | (Ubuntu) | | | | | | Date: | Sun, | 30 | Jan | 2022 | 12:50:54 | GMT | | Content-Type: | text/html | | | | | | | Content-Length: | 178 | | | | | | | Connection: | keep-alive | | | | | | | Location: | https://git.adrien.run/ | | | | | | | | | | | | | | ** Problème server de certificats Pour outrepasser les erreurs de certificat d'un server (certificat auto-signé par exemple), ajouter le paramètre ~--insecure~ ** Pour obtenir le code HTTP de retour #+BEGIN_SRC shell :output display result=$(curl -s -o /dev/null -w \"%{http_code}\" https://git.adrien.run) echo $result #+END_SRC #+RESULTS: : 200 * Références * [[https://curl.se/docs/manpage.html][Man page]] * [[https://yurisk.info/2020/03/13/curl-cookbook/][Yuri Slobodyanyuk curl cookbook]]