Welcome to the CHICKEN Scheme pasting service

http-client sent log to stderr added by sethalves on Fri Aug 30 01:29:11 2013

ponk% svn diff
Index: http-client.scm
===================================================================
--- http-client.scm     (revision 29481)
+++ http-client.scm     (working copy)
@@ -32,8 +32,8 @@
 ; OF THE POSSIBILITY OF SUCH DAMAGE.

 (module http-client
-  (max-retry-attempts max-redirect-depth retry-request? client-software
-   close-connection! close-all-connections!
+  (log-http-to-stderr max-retry-attempts max-redirect-depth retry-request?
+   client-software close-connection! close-all-connections!
    call-with-input-request with-input-from-request call-with-response
    store-cookie! delete-cookie! get-cookies-for-uri
    http-authenticators get-username/password
@@ -62,6 +62,8 @@

 (define-record http-connection base-uri inport outport proxy)

+(define log-http-to-stderr (make-parameter #f))
+
 (define max-retry-attempts (make-parameter 1))
 (define max-redirect-depth (make-parameter 5))

@@ -188,7 +190,28 @@
                                     'unsupported-uri-scheme
                                     'uri-scheme (uri-scheme remote-end)
                                     'request-uri uri 'proxy proxy)))
-         (let ((con (make-http-connection uri in out proxy)))
+         (let ((con (make-http-connection
+                     uri
+
+                     (if (log-http-to-stderr)
+                         (make-input-port
+                          (lambda ()
+                            (let ((v (read-char in)))
+                              (display v (current-error-port))
+                              v))
+                          (lambda () (char-ready? in))
+                          (lambda () (close-input-port in)))
+                         in)
+
+                     (if (log-http-to-stderr)
+                         (make-output-port
+                          (lambda (data)
+                            (display data (current-error-port))
+                            (write-string data (string-length data) out))
+                          (lambda () (close-output-port out)))
+                         out)
+
+                     proxy)))
            (add-connection! uri con)
            con)))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg provides `string-pad-right'?
Visually impaired? Let me spell it for you (wav file) download WAV