Hello! Andy Wingo <wi...@pobox.com> 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’.