anchor.diff:        (socket-stream browser-socket)
         :external-format (make-external-format :latin1 :eol-style :crlf))
        (usocket::host-to-hostname (get-peer-address browser-socket))
  -     (usocket::host-to-hostname (get-local-address browser-socket)))))
  +     (usocket::host-to-hostname (get-local-address browser-socket)))
  +    server-timeout))
   
  -(defun start-proxy (port hosts-table)
  +(defun start-proxy (port hosts-table &key
  +                    (client-timeout 2)
  +                    (server-timeout 2))
     "Start a reverse HTTP proxy on the specified port. hosts-table
   should consist of a list of hosts to be forwarded to particular IPs
  -and ports, like so: ((domain1 127.0.0.1 8080) (domain2 127.0.0.1 8081))
  +and ports, like so: ((domain1 127.0.0.1 8080) (domain2 127.0.0.1
  +8081)) The first entry in the hosts-table is the default forwarding
  +address if none of the entries match
   
  -Returns the main proxy server thread."
  +Returns the main proxy server thread.
  +
  +Optional parameters:
  +client-timeout (read and write) in seconds
  +server-timeout (read and write) in seconds"
     (bt:make-thread
      (lambda ()
        (with-server-socket (listener (socket-listen
  
positive.code:      host
       (when content-length (parse-integer content-length)))))
  
  (defun forward-response (hosts-table browser-stream forward-headers host
                           content-length)
    (declare (ignore content-length)) ;; for now
    (let ((server (cdr (or (assoc host hosts-table :test #'string=)
                           (car hosts-table)))))
      (with-client-socket (server-socket server-stream (car server) (cadr server)
                                         :element-type '(unsigned-byte 8))
        (set-timeout server-socket 2)
        (let ((s (make-flexi-stream server-stream :external-format :latin1)))
          (princ forward-headers s)
          (crlf s)
          (finish-output s))
        (let ((buffer (make-array 2048 :element-type '(unsigned-byte 8))))
          (loop for n = (read-sequence buffer server-stream) while (< 0 n)
             do (write-sequence buffer browser-stream :end n)
             finally (force-output browser-stream))))))
  
  (defun proxy-connection (browser-socket hosts-table)
    (set-timeout browser-socket 2)
    (multiple-value-call #'forward-response
      hosts-table
      (socket-stream browser-socket)
  
negative.code:               (let ((socket (socket-accept listener)))
                  (bt:make-thread
                   (lambda ()
                     (handler-case
                         (with-connected-socket (socket socket)
                           (proxy-connection socket hosts-table
                                             client-timeout server-timeout))
                       (error ())))
                   :name (format nil "simple-vhost-proxy (port ~A) connection thread"
                                 port)))
  