client.scm 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. ;;; Web client
  2. ;; Copyright (C) 2011-2018, 2020-2022 Free Software Foundation, Inc.
  3. ;; This library is free software; you can redistribute it and/or
  4. ;; modify it under the terms of the GNU Lesser General Public
  5. ;; License as published by the Free Software Foundation; either
  6. ;; version 3 of the License, or (at your option) any later version.
  7. ;;
  8. ;; This library is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ;; Lesser General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU Lesser General Public
  14. ;; License along with this library; if not, write to the Free Software
  15. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. ;; 02110-1301 USA
  17. ;;; Commentary:
  18. ;;;
  19. ;;; (web client) is a simple HTTP URL fetcher for Guile.
  20. ;;;
  21. ;;; In its current incarnation, (web client) is synchronous. If you
  22. ;;; want to fetch a number of URLs at once, probably the best thing to
  23. ;;; do is to write an event-driven URL fetcher, similar in structure to
  24. ;;; the web server.
  25. ;;;
  26. ;;; Another option, good but not as performant, would be to use threads,
  27. ;;; possibly via a thread pool.
  28. ;;;
  29. ;;; Code:
  30. (define-module (web client)
  31. #:use-module (rnrs bytevectors)
  32. #:use-module (ice-9 binary-ports)
  33. #:use-module (ice-9 copy-tree)
  34. #:use-module (ice-9 iconv)
  35. #:use-module (web request)
  36. #:use-module (web response)
  37. #:use-module (web uri)
  38. #:use-module (web http)
  39. #:use-module (srfi srfi-1)
  40. #:use-module (srfi srfi-9)
  41. #:use-module (srfi srfi-9 gnu)
  42. #:use-module (srfi srfi-26)
  43. #:use-module (ice-9 match)
  44. #:autoload (ice-9 ftw) (scandir)
  45. #:export (current-http-proxy
  46. current-https-proxy
  47. x509-certificate-directory
  48. open-socket-for-uri
  49. http-request
  50. http-get
  51. http-head
  52. http-post
  53. http-put
  54. http-delete
  55. http-trace
  56. http-options))
  57. (define %http-receive-buffer-size
  58. ;; Size of the HTTP receive buffer.
  59. 65536)
  60. ;; Autoload GnuTLS so that this module can be used even when GnuTLS is
  61. ;; not available. At compile time, this yields "possibly unbound
  62. ;; variable" warnings, but these are OK: they'll be resolved at run time
  63. ;; thanks to 'load-gnutls'.
  64. (define (load-gnutls)
  65. "Attempt to load the (gnutls) module. Throw to 'gnutls-not-available
  66. if it is unavailable."
  67. (catch 'misc-error
  68. (lambda ()
  69. ;; XXX: Use this hack instead of #:autoload to avoid compilation
  70. ;; errors. See <http://bugs.gnu.org/12202>.
  71. (module-use! (resolve-module '(web client))
  72. (resolve-interface '(gnutls))))
  73. (lambda _
  74. (throw 'gnutls-not-available "(gnutls) module not available")))
  75. (set! load-gnutls (const #t)))
  76. (define current-http-proxy
  77. (make-parameter (let ((proxy (getenv "http_proxy")))
  78. (and (not (equal? proxy ""))
  79. proxy))))
  80. (define current-https-proxy
  81. (make-parameter (let ((proxy (getenv "https_proxy")))
  82. (and (not (equal? proxy ""))
  83. proxy))))
  84. (define x509-certificate-directory
  85. ;; The directory where X.509 authority PEM certificates are stored.
  86. (make-parameter (or (getenv "GUILE_TLS_CERTIFICATE_DIRECTORY")
  87. (getenv "SSL_CERT_DIR") ;like OpenSSL
  88. "/etc/ssl/certs")))
  89. (define (set-certificate-credentials-x509-trust-file!* cred file format)
  90. "Like 'set-certificate-credentials-x509-trust-file!', but without the file
  91. name decoding bug described at
  92. <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26948#17>."
  93. (let ((data (call-with-input-file file get-bytevector-all)))
  94. (set-certificate-credentials-x509-trust-data! cred data format)))
  95. (define (make-credendials-with-ca-trust-files directory)
  96. "Return certificate credentials with X.509 authority certificates read from
  97. DIRECTORY. Those authority certificates are checked when
  98. 'peer-certificate-status' is later called."
  99. (let ((cred (make-certificate-credentials))
  100. (files (match (scandir directory (cut string-suffix? ".pem" <>))
  101. ((or #f ())
  102. ;; Some distros provide nothing but bundles (*.crt) under
  103. ;; /etc/ssl/certs, so look for them.
  104. (or (scandir directory (cut string-suffix? ".crt" <>))
  105. '()))
  106. (pem pem))))
  107. (for-each (lambda (file)
  108. (let ((file (string-append directory "/" file)))
  109. ;; Protect against dangling symlinks.
  110. (when (file-exists? file)
  111. (set-certificate-credentials-x509-trust-file!*
  112. cred file
  113. x509-certificate-format/pem))))
  114. files)
  115. cred))
  116. (define (peer-certificate session)
  117. "Return the certificate of the remote peer in SESSION."
  118. (match (session-peer-certificate-chain session)
  119. ((first _ ...)
  120. (import-x509-certificate first x509-certificate-format/der))))
  121. (define (assert-valid-server-certificate session server)
  122. "Return #t if the certificate of the remote peer for SESSION is a valid
  123. certificate for SERVER, where SERVER is the expected host name of peer."
  124. (define cert
  125. (peer-certificate session))
  126. ;; First check whether the server's certificate matches SERVER.
  127. (unless (x509-certificate-matches-hostname? cert server)
  128. (throw 'tls-certificate-error 'host-mismatch cert server))
  129. ;; Second check its validity and reachability from the set of authority
  130. ;; certificates loaded via 'set-certificate-credentials-x509-trust-file!'.
  131. (match (peer-certificate-status session)
  132. (() ;certificate is valid
  133. #t)
  134. ((statuses ...)
  135. (throw 'tls-certificate-error 'invalid-certificate cert server
  136. statuses))))
  137. (define (print-tls-certificate-error port key args default-printer)
  138. "Print the TLS certificate error represented by ARGS in an intelligible
  139. way."
  140. (match args
  141. (('host-mismatch cert server)
  142. (format port
  143. "X.509 server certificate for '~a' does not match: ~a~%"
  144. server (x509-certificate-dn cert)))
  145. (('invalid-certificate cert server statuses)
  146. (format port
  147. "X.509 certificate of '~a' could not be verified:~% ~a~%"
  148. server
  149. (string-join (map certificate-status->string statuses))))))
  150. (set-exception-printer! 'tls-certificate-error
  151. print-tls-certificate-error)
  152. (define (wrap-record-port-for-gnutls<3.7.7 record port)
  153. "Return a port that wraps RECORD to ensure that closing it also closes PORT,
  154. the actual socket port, and its file descriptor. Make sure it does not
  155. introduce extra buffering (custom ports are buffered by default as of Guile
  156. 3.0.5).
  157. This wrapper is unnecessary with GnuTLS >= 3.7.7, which can automatically
  158. close SESSION's file descriptor when RECORD is closed."
  159. (define (read! bv start count)
  160. (define read
  161. (catch 'gnutls-error
  162. (lambda ()
  163. (get-bytevector-n! record bv start count))
  164. (lambda (key err proc . rest)
  165. ;; When responding to "Connection: close" requests, some servers
  166. ;; close the connection abruptly after sending the response body,
  167. ;; without doing a proper TLS connection termination. Treat it as
  168. ;; EOF. This is fixed in GnuTLS 3.7.7.
  169. (if (eq? err error/premature-termination)
  170. the-eof-object
  171. (apply throw key err proc rest)))))
  172. (if (eof-object? read)
  173. 0
  174. read))
  175. (define (write! bv start count)
  176. (put-bytevector record bv start count)
  177. (force-output record)
  178. count)
  179. (define (get-position)
  180. (port-position record))
  181. (define (set-position! new-position)
  182. (set-port-position! record new-position))
  183. (define (close)
  184. (unless (port-closed? port)
  185. (close-port port))
  186. (unless (port-closed? record)
  187. (close-port record)))
  188. (define (unbuffered port)
  189. (setvbuf port 'none)
  190. port)
  191. (unbuffered
  192. (make-custom-binary-input/output-port "gnutls wrapped port" read! write!
  193. get-position set-position!
  194. close)))
  195. (define* (tls-wrap port server #:key (verify-certificate? #t))
  196. "Return PORT wrapped in a TLS connection to SERVER. SERVER must be a DNS
  197. host name without trailing dot."
  198. (define (log level str)
  199. (format (current-error-port)
  200. "gnutls: [~a|~a] ~a" (getpid) level str))
  201. (load-gnutls)
  202. (let ((session (make-session connection-end/client))
  203. (ca-certs (x509-certificate-directory)))
  204. ;; Some servers such as 'cloud.github.com' require the client to support
  205. ;; the 'SERVER NAME' extension. However, 'set-session-server-name!' is
  206. ;; not available in older GnuTLS releases. See
  207. ;; <http://bugs.gnu.org/18526> for details.
  208. (if (module-defined? (resolve-interface '(gnutls))
  209. 'set-session-server-name!)
  210. (set-session-server-name! session server-name-type/dns server)
  211. (format (current-error-port)
  212. "warning: TLS 'SERVER NAME' extension not supported~%"))
  213. (set-session-transport-fd! session (fileno port))
  214. (set-session-default-priority! session)
  215. ;; The "%COMPAT" bit allows us to work around firewall issues (info
  216. ;; "(gnutls) Priority Strings"); see <http://bugs.gnu.org/23311>.
  217. ;; Explicitly disable SSLv3, which is insecure:
  218. ;; <https://tools.ietf.org/html/rfc7568>.
  219. (set-session-priorities! session "NORMAL:%COMPAT:-VERS-SSL3.0")
  220. (set-session-credentials! session
  221. (if verify-certificate?
  222. (make-credendials-with-ca-trust-files
  223. ca-certs)
  224. (make-certificate-credentials)))
  225. ;; Uncomment the following lines in case of debugging emergency.
  226. ;;(set-log-level! 10)
  227. ;;(set-log-procedure! log)
  228. (let loop ((retries 5))
  229. (catch 'gnutls-error
  230. (lambda ()
  231. (handshake session))
  232. (lambda (key err proc . rest)
  233. (cond ((eq? err error/warning-alert-received)
  234. ;; Like Wget, do no stop upon non-fatal alerts such as
  235. ;; 'alert-description/unrecognized-name'.
  236. (format (current-error-port)
  237. "warning: TLS warning alert received: ~a~%"
  238. (alert-description->string (alert-get session)))
  239. (handshake session))
  240. (else
  241. (if (or (fatal-error? err) (zero? retries))
  242. (apply throw key err proc rest)
  243. (begin
  244. ;; We got 'error/again' or similar; try again.
  245. (format (current-error-port)
  246. "warning: TLS non-fatal error: ~a~%"
  247. (error->string err))
  248. (loop (- retries 1)))))))))
  249. ;; Verify the server's certificate if needed.
  250. (when verify-certificate?
  251. (catch 'tls-certificate-error
  252. (lambda ()
  253. (assert-valid-server-certificate session server))
  254. (lambda args
  255. (close-port port)
  256. (apply throw args))))
  257. (let ((record (session-record-port session)))
  258. (setvbuf record 'block)
  259. (if (module-defined? (resolve-interface '(gnutls))
  260. 'set-session-record-port-close!) ;GnuTLS >= 3.7.7
  261. (let ((close-wrapped-port (lambda (_) (close-port port))))
  262. (set-session-record-port-close! record close-wrapped-port)
  263. record)
  264. (wrap-record-port-for-gnutls<3.7.7 record port)))))
  265. (define (ensure-uri-reference uri-or-string)
  266. (cond
  267. ((string? uri-or-string) (string->uri-reference uri-or-string))
  268. ((uri-reference? uri-or-string) uri-or-string)
  269. (else (error "Invalid URI-reference" uri-or-string))))
  270. (define (setup-http-tunnel port uri)
  271. "Establish over PORT an HTTP tunnel to the destination server of URI."
  272. (define target
  273. (string-append (uri-host uri) ":"
  274. (number->string
  275. (or (uri-port uri)
  276. (match (uri-scheme uri)
  277. ('http 80)
  278. ('https 443))))))
  279. (format port "CONNECT ~a HTTP/1.1\r\n" target)
  280. (format port "Host: ~a\r\n\r\n" target)
  281. (force-output port)
  282. (read-response port))
  283. (define* (open-socket-for-uri uri-or-string
  284. #:key (verify-certificate? #t))
  285. "Return an open input/output port for a connection to URI-OR-STRING.
  286. When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates."
  287. (define uri
  288. (ensure-uri-reference uri-or-string))
  289. (define https?
  290. (eq? 'https (uri-scheme uri)))
  291. (define (open-socket)
  292. (define http-proxy
  293. (if https? (current-https-proxy) (current-http-proxy)))
  294. (define uri (ensure-uri-reference (or http-proxy uri-or-string)))
  295. (define addresses
  296. (let ((port (uri-port uri)))
  297. (delete-duplicates
  298. (getaddrinfo (uri-host uri)
  299. (cond (port => number->string)
  300. ((uri-scheme uri) => symbol->string)
  301. (else (error "Not an absolute URI" uri)))
  302. (if port
  303. AI_NUMERICSERV
  304. 0))
  305. (lambda (ai1 ai2)
  306. (equal? (addrinfo:addr ai1) (addrinfo:addr ai2))))))
  307. (let loop ((addresses addresses))
  308. (let* ((ai (car addresses))
  309. (s (with-fluids ((%default-port-encoding #f))
  310. ;; Restrict ourselves to TCP.
  311. (socket (addrinfo:fam ai) SOCK_STREAM IPPROTO_IP))))
  312. (catch 'system-error
  313. (lambda ()
  314. (connect s (addrinfo:addr ai))
  315. ;; Buffer input and output on this port.
  316. (setvbuf s 'block)
  317. ;; If we're using a proxy, make a note of that.
  318. (when http-proxy (set-http-proxy-port?! s #t))
  319. s)
  320. (lambda args
  321. ;; Connection failed, so try one of the other addresses.
  322. (close s)
  323. (if (null? (cdr addresses))
  324. (apply throw args)
  325. (loop (cdr addresses))))))))
  326. (let ((s (open-socket)))
  327. ;; Buffer input and output on this port.
  328. (setvbuf s 'block %http-receive-buffer-size)
  329. (when (and https? (current-https-proxy))
  330. (setup-http-tunnel s uri))
  331. (if https?
  332. (tls-wrap s (uri-host uri)
  333. #:verify-certificate? verify-certificate?)
  334. s)))
  335. (define (extend-request r k v . additional)
  336. (let ((r (set-field r (request-headers)
  337. (assoc-set! (copy-tree (request-headers r))
  338. k v))))
  339. (if (null? additional)
  340. r
  341. (apply extend-request r additional))))
  342. ;; -> request body
  343. (define (sanitize-request request body)
  344. "\"Sanitize\" the given request and body, ensuring that they are
  345. complete and coherent. This method is most useful for methods that send
  346. data to the server, like POST, but can be used for any method. Return
  347. two values: a request and a bytevector, possibly the same ones that were
  348. passed as arguments.
  349. If BODY is a string, encodes the string to a bytevector, in an encoding
  350. appropriate for REQUEST. Adds a ‘content-length’ and ‘content-type’
  351. header, as necessary.
  352. If BODY is a procedure, it is called with a port as an argument, and the
  353. output collected as a bytevector. In the future we might try to instead
  354. use a compressing, chunk-encoded port, and call this procedure later.
  355. Authors are advised not to rely on the procedure being called at any
  356. particular time.
  357. Note that we rely on the request itself already having been validated,
  358. as is the case by default with a request returned by `build-request'."
  359. (cond
  360. ((not body)
  361. (let ((length (request-content-length request)))
  362. (if length
  363. ;; FIXME make this stricter: content-length header should be
  364. ;; prohibited if there's no body, even if the content-length
  365. ;; is 0.
  366. (unless (zero? length)
  367. (error "content-length, but no body"))
  368. (when (assq 'transfer-encoding (request-headers request))
  369. (error "transfer-encoding not allowed with no body")))
  370. (values request #vu8())))
  371. ((string? body)
  372. (let* ((type (request-content-type request '(text/plain)))
  373. (declared-charset (assq-ref (cdr type) 'charset))
  374. (charset (or declared-charset "utf-8")))
  375. (sanitize-request
  376. (if declared-charset
  377. request
  378. (extend-request request 'content-type
  379. `(,@type (charset . ,charset))))
  380. (string->bytevector body charset))))
  381. ((procedure? body)
  382. (let* ((type (request-content-type request
  383. '(text/plain)))
  384. (declared-charset (assq-ref (cdr type) 'charset))
  385. (charset (or declared-charset "utf-8")))
  386. (sanitize-request
  387. (if declared-charset
  388. request
  389. (extend-request request 'content-type
  390. `(,@type (charset . ,charset))))
  391. (call-with-encoded-output-string charset body))))
  392. ((not (bytevector? body))
  393. (error "unexpected body type"))
  394. (else
  395. (values (let ((rlen (request-content-length request))
  396. (blen (bytevector-length body)))
  397. (cond
  398. (rlen (if (= rlen blen)
  399. request
  400. (error "bad content-length" rlen blen)))
  401. (else (extend-request request 'content-length blen))))
  402. body))))
  403. (define (decode-response-body response body)
  404. ;; `body' is either #f or a bytevector.
  405. (cond
  406. ((not body) body)
  407. ((bytevector? body)
  408. (let ((rlen (response-content-length response))
  409. (blen (bytevector-length body)))
  410. (cond
  411. ((and rlen (not (= rlen blen)))
  412. (error "bad content-length" rlen blen))
  413. ((response-content-type response)
  414. => (lambda (type)
  415. (cond
  416. ((text-content-type? (car type))
  417. ;; RFC 2616 3.7.1: "When no explicit charset parameter is
  418. ;; provided by the sender, media subtypes of the "text"
  419. ;; type are defined to have a default charset value of
  420. ;; "ISO-8859-1" when received via HTTP."
  421. (bytevector->string body (or (assq-ref (cdr type) 'charset)
  422. "iso-8859-1")))
  423. (else body))))
  424. (else body))))
  425. (else
  426. (error "unexpected body type" body))))
  427. (define* (http-request uri #:key
  428. (body #f)
  429. (verify-certificate? #t)
  430. (port (open-socket-for-uri uri
  431. #:verify-certificate?
  432. verify-certificate?))
  433. (method 'GET)
  434. (version '(1 . 1))
  435. (keep-alive? #f)
  436. (headers '())
  437. (decode-body? #t)
  438. (streaming? #f)
  439. (request
  440. (build-request
  441. (ensure-uri-reference uri)
  442. #:method method
  443. #:version version
  444. #:headers (if keep-alive?
  445. headers
  446. (cons '(connection close) headers))
  447. #:port port)))
  448. "Connect to the server corresponding to URI and ask for the resource,
  449. using METHOD, defaulting to ‘GET’. If you already have a port open,
  450. pass it as PORT. The port will be closed at the end of the request
  451. unless KEEP-ALIVE? is true. Any extra headers in the alist HEADERS will
  452. be added to the request.
  453. If BODY is not ‘#f’, a message body will also be sent with the HTTP
  454. request. If BODY is a string, it is encoded according to the
  455. content-type in HEADERS, defaulting to UTF-8. Otherwise BODY should be
  456. a bytevector, or ‘#f’ for no body. Although it's allowed to send a
  457. message body along with any request, usually only POST and PUT requests
  458. have bodies. See ‘http-put’ and ‘http-post’ documentation, for more.
  459. If DECODE-BODY? is true, as is the default, the body of the
  460. response will be decoded to string, if it is a textual content-type.
  461. Otherwise it will be returned as a bytevector.
  462. However, if STREAMING? is true, instead of eagerly reading the response
  463. body from the server, this function only reads off the headers. The
  464. response body will be returned as a port on which the data may be read.
  465. Unless KEEP-ALIVE? is true, the port will be closed after the full
  466. response body has been read.
  467. If PORT is false, URI denotes an HTTPS URL, and VERIFY-CERTIFICATE? is
  468. true, verify X.509 certificates against those available in
  469. X509-CERTIFICATE-DIRECTORY.
  470. Returns two values: the response read from the server, and the response
  471. body as a string, bytevector, #f value, or as a port (if STREAMING? is
  472. true)."
  473. (call-with-values (lambda () (sanitize-request request body))
  474. (lambda (request body)
  475. (let ((request (write-request request port)))
  476. (when body
  477. (write-request-body request body))
  478. (force-output (request-port request))
  479. (let ((response (read-response port)))
  480. (cond
  481. ((eq? (request-method request) 'HEAD)
  482. (unless keep-alive?
  483. (close-port port))
  484. (values response #f))
  485. (streaming?
  486. (values response
  487. (response-body-port response
  488. #:keep-alive? keep-alive?
  489. #:decode? decode-body?)))
  490. (else
  491. (let ((body (read-response-body response)))
  492. (unless keep-alive?
  493. (close-port port))
  494. (values response
  495. (if decode-body?
  496. (decode-response-body response body)
  497. body))))))))))
  498. (define-syntax-rule (define-http-verb http-verb method doc)
  499. (define* (http-verb uri #:key
  500. (body #f)
  501. (verify-certificate? #t)
  502. (port (open-socket-for-uri uri
  503. #:verify-certificate?
  504. verify-certificate?))
  505. (version '(1 . 1))
  506. (keep-alive? #f)
  507. (headers '())
  508. (decode-body? #t)
  509. (streaming? #f))
  510. doc
  511. (http-request uri
  512. #:body body #:method method
  513. #:port port #:version version #:keep-alive? keep-alive?
  514. #:headers headers #:decode-body? decode-body?
  515. #:verify-certificate? verify-certificate?
  516. #:streaming? streaming?)))
  517. (define-http-verb http-get
  518. 'GET
  519. "Fetch message headers for the given URI using the HTTP \"GET\"
  520. method.
  521. This function invokes ‘http-request’, with the \"GET\" method. See
  522. ‘http-request’ for full documentation on the various keyword arguments
  523. that are accepted by this function.
  524. Returns two values: the resulting response, and the response body.")
  525. (define-http-verb http-head
  526. 'HEAD
  527. "Fetch message headers for the given URI using the HTTP \"HEAD\"
  528. method.
  529. This function invokes ‘http-request’, with the \"HEAD\" method. See
  530. ‘http-request’ for full documentation on the various keyword arguments
  531. that are accepted by this function.
  532. Returns two values: the resulting response, and ‘#f’. Responses to HEAD
  533. requests do not have a body. The second value is only returned so that
  534. other procedures can treat all of the http-foo verbs identically.")
  535. (define-http-verb http-post
  536. 'POST
  537. "Post data to the given URI using the HTTP \"POST\" method.
  538. This function invokes ‘http-request’, with the \"POST\" method. See
  539. ‘http-request’ for full documentation on the various keyword arguments
  540. that are accepted by this function.
  541. Returns two values: the resulting response, and the response body.")
  542. (define-http-verb http-put
  543. 'PUT
  544. "Put data at the given URI using the HTTP \"PUT\" method.
  545. This function invokes ‘http-request’, with the \"PUT\" method. See
  546. ‘http-request’ for full documentation on the various keyword arguments
  547. that are accepted by this function.
  548. Returns two values: the resulting response, and the response body.")
  549. (define-http-verb http-delete
  550. 'DELETE
  551. "Delete data at the given URI using the HTTP \"DELETE\" method.
  552. This function invokes ‘http-request’, with the \"DELETE\" method. See
  553. ‘http-request’ for full documentation on the various keyword arguments
  554. that are accepted by this function.
  555. Returns two values: the resulting response, and the response body.")
  556. (define-http-verb http-trace
  557. 'TRACE
  558. "Send an HTTP \"TRACE\" request.
  559. This function invokes ‘http-request’, with the \"TRACE\" method. See
  560. ‘http-request’ for full documentation on the various keyword arguments
  561. that are accepted by this function.
  562. Returns two values: the resulting response, and the response body.")
  563. (define-http-verb http-options
  564. 'OPTIONS
  565. "Query characteristics of an HTTP resource using the HTTP \"OPTIONS\"
  566. method.
  567. This function invokes ‘http-request’, with the \"OPTIONS\" method. See
  568. ‘http-request’ for full documentation on the various keyword arguments
  569. that are accepted by this function.
  570. Returns two values: the resulting response, and the response body.")