anchor.diff:          original-method)))
   
   (defun setup-parser (sock)
  -  "Setup a parser on a socket. This can be called multiple times on the same
  -   socket (usually at the end of a request) so that if another request comes in
  -   on the same connect, we'll have reset state =]"
  +  "This is the main parser function. It's responsible for listening to a socket,
  +   setting up an HTTP parser for it, handling the different events/callbacks the
  +   HTTP parser throws at it, dispatching routes, handling body chunking, etc. A
  +   lot of this is done via shared state which all lives under this function's
  +   top-level (let) form, and a set of local functions which read/modify this
  +   shared state.
  +
  +   This function is at the core of Wookie's being.
  +
  +   Note that setup-parser can be called multiple times on the same socket. The
  +   only reason to do this is if a request/response has come and gone on the
  +   socket and you wish to make the socket available for another request. Wookie
  +   handles all of this automatically."
     (let* ((http (make-instance 'http-parse:http-request))
            (route-path nil)
            (route nil)  ; holds the current route, filled in below once we get headers
  
positive.code:                    (setf error-occurred-p t)
                     (main-event-handler e sock))))
               (body-callback (chunk finishedp)
                 (when error-occurred-p
                   (return-from body-callback))
                 ;; forward the chunk to the callback provided in the chunk-enabled
  
negative.code:                                 ;; body callback will never be called).
                                  (let ((request-body-cb (request-body-callback request)))
                                    (when (and (getf route :allow-chunking)
                                               (getf route :buffer-body))
                                      (if (and body-buffer
                                               body-finished-p)
                                          ;; the body has finished processing, either
                                          ;; send it into the chunking function or set
                                          ;; up a callback that is called when
                                          ;; with-chunking is called that pumps the body
                                          ;; into the newly setup chunking callback
                                          (let ((body (flex:get-output-stream-sequence body-buffer)))
                                            (if request-body-cb
                                                ;; with-chunking already called, great. pass
                                                ;; in the body
                                                (funcall request-body-cb body t)
                                                ;; set up a callback that fires when
                                                ;; with-chunking is called. it'll pass the
                                                ;; body into the with-chunking callback
                                                ;; once set
                                                (setf (request-body-callback-setcb request) (lambda (body-cb) (funcall body-cb body t)))))
                                          ;; chunking hasn't started yet AND we haven't called
                                          ;; with-chunking yet. this is kind of an edge case,
                                          ;; but it needs to be handled. we set up a callback
                                          ;; that runs once with-chunking is called that
                                          ;; *hopes* the body has finished chunking and if so,
                                          ;; fires with-chunking with the body.
                                          (setf (request-body-callback-setcb request) (lambda (body-cb)
                                                                                        (let ((body (flex:get-output-stream-sequence body-buffer)))
                                                                                          (when body
                                                                                            (funcall body-cb body t)))))))))
                                (progn
                                  (log:warn "(route) Missing route: ~s" route)
                                  (funcall 'main-event-handler (make-instance 'route-not-found
  