[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module: (web client)
From: |
Ludovic Courtès |
Subject: |
Re: new module: (web client) |
Date: |
Mon, 18 Jul 2011 14:59:46 +0200 |
User-agent: |
Gnus/5.110017 (No Gnus v0.17) Emacs/24.0.50 (gnu/linux) |
Hello!
Andy Wingo <address@hidden> skribis:
> I wrote a simple HTTP client and dropped it in (web client). It's
> synchronous, so it's a bit lame. I'm attaching it here for review.
> Feedback welcome.
This looks great!
> ;;; (web client) is a simple HTTP URL fetcher for Guile.
> ;;;
> ;;; In its current incarnation, (web client) is synchronous. If you
> ;;; want to fetch a number of URLs at once, probably the best thing to
> ;;; do is to write an event-driven URL fetcher, similar in structure to
> ;;; the web server.
> ;;;
> ;;; Another option, good but not as performant, would be to use threads,
> ;;; possibly via par-map or futures.
Futures are for computational tasks, so I think you’d want something
akin to futures but where the number of concurrent tasks isn’t related
to the number of CPU cores.
> (define (open-socket-for-uri uri)
> (let* ((ai (car (getaddrinfo (uri-host uri)
What if URI is file://foo?
> (define (text-type? type)
> (let ((type (symbol->string type)))
> (or (string-prefix? "text/" type)
> (string-suffix? "/xml" type)
> (string-suffix? "+xml" type))))
We need a MIME lib. :-)
Besides, it would be nice to have docstrings at least for the public
procedures.
Thanks!
Ludo’.