Trivial-HTTP

Ah, HTTP, the protocol we all love to re-implement. Lispers now have several options open to them for adding HTTP support to their code.

* Drakma for a protocol-conforming, advanced HTTP/1.1 client library all written in lisp.

* CL-curl reaches out to libCurl

* and then there's trivial-http. It is a trivial networking library for doing HTTP POST, HEAD and GET (web client operations) over a socket interface. It establishes a package TRIVIAL-HTTP, also called THTTP.

If you just need simple HTTP operations (no chunking, no flexistreams, etc,) then trivial-http may be what you're looking for.

Download ASDF package from http://common-lisp.net/project/trivial-http/trivial-http.tar.gz

Older stuff that will disappear someday

(THTTP:HTTP-GET URL) - returns a list of three elements: a response code as integer, an association list of headers returned from the server, and a stream from which the response can be read.

(THTTP:HTTP-POST URL CONTENT-TYPE CONTENT) - given a URL, a MIME content type, and the content as a character stream, POST to the URL and return the list of three elements as described for HTTP-GET.

(THTTP:ESCAPE-URL-QUERY QUERY) - escapes a query string in accordance with the HTTP specification.

A Subversion repository is available over anonymous SVNServe at the following URL:

svn://unmutual.info/trivial-http

For those who'd really quite like to download images, this paste should do it.

I just added support for arbitrary headers. Here is the paste. -- BrianRowe

If trivial-http is insufficient for your intended task, for example, you need to send cookies, see cl-curl for an interface to the libcurl library.

I had to alter the constant +crlf+ to hold (string #\newline) to make things work under Windows and Clisp

I'm not really sure why that would be necessary. Right now trivial-http is sending a raw CR, LF pair; I'm not sure what clisp did to break this. -- Brian Mastenbrook

Uh, you're doing character output, so clisp will have an external format on your character output stream. That external format, on Windows, is likely to convert a #\Newline character to CRLF; I suspect that there is also an identity where #\Newline is #\Linefeed, so Brian's +crlf+ ends up sending out CRLFLF. In Summary: HTTP is a binary protocol. -- Christophe

Web


This page is linked from: ASDF-Install-Tester   Categorized Libraries   cl-curl   cl-yahoo   simple-http   trivial-https   wilbur-web  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively