#lang scheme
(require (prefix-in channel: "channel.ss"))
(require "pool.ss")
(require "parse.ss")
(require net/url)
(require srfi/19)
(define request-headers
(set-headers
#f
`(("Host" . "google.com")
("User-Agent" . "test0r")
("Date" . ,(current-date)))))
(define (test)
(thread
(λ ()
(define-values (request response) (connect 'get (string->url "http://www.google.com/") request-headers))
(define-values (version code message headers) (channel:get response))
(display (format "*** ~s ~s~n" code message))
(display (get-header headers "Content-Length"))(display "\n")
(call-with-output-file "goog.html" #:exists 'replace
(λ (goog)
(copy-port (channel:get response) goog)))
23)))
(let ([threads
(map (λ (i)
(sleep 0.001)
(test))
'(1 2 3 4))])
(for-each thread-wait threads))