You are looking at historical revision 15028 of this page. It may differ significantly from its current revision.
Http-client is a highlevel HTTP client library.
This egg is still very much under development; the API should be considered to be unstable and can change heavily from version to version.
Main request procedures
All these procedures accept intarweb request objects, uri-common uri objects or strings. In case of an uri-common object, (make-request uri: uri-common) is used to convert the URI object to a request object. In case of a string, the string is first converted to a URI-common object and then converted to a request object. The upshot of all this is that it becomes extremely easy to perform basic GET requests.[procedure] (call-with-response uri-or-request [writer] reader)
This is the core http-client procedure. It is only necessary to use this when you want the most control over the request/response cycle. uri-or-request is the request object, uri or string that contains information about the request to perform. reader is a procedure that receives the response object and should read the request body, writer is an optional procedure that receives the request object and should write the request body.
The writer should be prepared to be called several times; if the response is a redirect or some other status that indicates the server wants the client to perform a new request, the writer should be ready to write a request body for this new request.
Returns three values: The result of the call to reader, the request-uri of the last request and the response object. The request-uri is useful because this is to be used as the base uri of the document. This can differ from the initial request in the presence of redirects.[procedure] (call-with-input-request uri-or-request reader)
This procedure simply calls the reader with one argument: an input port from which the response body can be read.
Returns three values: The result of the call to reader, the request-uri of the last request and the response object. If the response code is not in the 200 class, it will throw an exception of type client-error, server-error or unexpected-server-response, depending on the response code. This includes 404 not found (which is a client-error).[procedure] (with-input-request uri-or-request thunk)
Same as call-with-input-request, except this accepts a thunk (lambda of no arguments) which will be executed with current-input-port bound to the response port.
<example> <init>(use http-client)</init> <expr>(with-input-from-request "http://chicken.wiki.br/" read-string)</expr> <result>"[the chicken wiki page HTML contents]"</result> </example>
- 0.1 Initial version
Copyright (c) 2008-2009, Peter Bex Parts copyright (c) 2000-2004, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.