Anonymous user
HTTP: Difference between revisions
Emacs Lisp: Improve solution, add asynchronous version
Thundergnat (talk | contribs) m (→{{header|Raku}}: Remove unnecessary and deprecated pragma) |
(Emacs Lisp: Improve solution, add asynchronous version) |
||
Line 1,066:
=={{header|Emacs Lisp}}==
<code>url.el</code> can download HTTP. <code>url-retrieve-synchronously</code> returns a buffer containing headers and body. Caller kills the buffer when no longer required.▼
{libheader|url.el}}
▲
(url-retrieve-synchronously "http://www.rosettacode.org")▼
(unwind-protect
(prin1 (buffer-substring (point) (point-max)))▼
(kill-buffer buffer)))</lang>
Asynchronously (buffer doesn't need to be killed by caller):
<lang Lisp>(url-retrieve "http://www.rosettacode.org"
(lambda (_status)
(message "%s" (buffer-substring url-http-end-of-headers (point-max)))))</lang>
=={{header|Erlang}}==
|