diff --git a/src/fast-http.lisp b/src/fast-http.lisp index b27ea97..1625732 100644 --- a/src/fast-http.lisp +++ b/src/fast-http.lisp @@ -100,7 +100,7 @@ :invalid-parameter-value)) (in-package :fast-http) -(defun-careful make-parser (http &key first-line-callback header-callback body-callback finish-callback) +(defun-careful make-parser (http &key first-line-callback header-callback body-callback finish-callback (head-request nil)) (declare (type http http)) (let (callbacks @@ -217,7 +217,7 @@ end nil)) (setf (http-mark http) start) (handler-case - (funcall parse-fn http callbacks (the simple-byte-vector data) :start start :end end) + (funcall parse-fn http callbacks (the simple-byte-vector data) :start start :end end :head-request head-request) (eof () (setq data-buffer (subseq data (http-mark http) (or end (length data))))))))) diff --git a/src/parser.lisp b/src/parser.lisp index 31c05c5..125f8dc 100644 --- a/src/parser.lisp +++ b/src/parser.lisp @@ -474,7 +474,7 @@ us a never-ending header that the application keeps buffering.") (decf (http-content-length http) readable-count) (callback-data :body http callbacks data start end) (setf (http-mark http) end) - (values end (= readable-count 0)))))) + (values end nil))))) (defun-speedy http-message-needs-eof-p (http) (let ((status-code (http-status http))) @@ -622,9 +622,10 @@ us a never-ending header that the application keeps buffering.") (callback-notify :message-complete http callbacks))))) (error 'eof))) -(defun-speedy parse-request (http callbacks data &key (start 0) end) +(defun-speedy parse-request (http callbacks data &key (start 0) end (head-request nil)) (declare (type http http) - (type simple-byte-vector data)) + (type simple-byte-vector data) + (ignore head-request)) (let ((end (or end (length data)))) (declare (type pointer start end)) (handler-bind ((match-failed @@ -727,7 +728,7 @@ us a never-ending header that the application keeps buffering.") (return-from parse-request (pos))))) (error 'eof))) -(defun-speedy parse-response (http callbacks data &key (start 0) end) +(defun-speedy parse-response (http callbacks data &key (start 0) end (head-request nil)) (declare (type http http) (type simple-byte-vector data)) (let ((end (or end @@ -785,6 +786,11 @@ us a never-ending header that the application keeps buffering.") +state-chunk-size+ +state-body+)) + (when head-request + (callback-notify :message-complete http callbacks) + (setf (http-state http) +state-first-line+) + (return-from parse-response (pos))) + body (if (http-chunked-p http) (advance-to* (parse-chunked-body http callbacks data (pos) end))