With Open HTTP Resource

Open a stream to a resource on the web, evaluate forms, then close the stream.
with-open-http-resource (var url) {form}*

First bind a variable to a stream created by sending a request to the web server of the URL. Then evaluates the body forms, typically reading content from the stream. Finally closes the stream, returning the values of the last form.

The stream is closed whether or not an error was encountered while reading from the resource. The scope of the stream object is limited to the body of the form.

This construct is the web counterpart to the with-open-file of Common LISP.

No side-effects except for eventual consequences for the accessed web server.

(with-open-http-resource (in "http://interaction.in-progress.com/index")
 (read-line in))

Related: with-open-cgi

Interaction Developer Reference


This site is enhanced with Interaction.