Commit ea2dd421 authored by Eric Timmons's avatar Eric Timmons

Be a little smarter about requesting HTTP offsets

parent 0958403d
......@@ -55,28 +55,32 @@
(accept-ranges)
headers
(last-modified))
(multiple-value-bind (content code headers)
(http-client-request (http-index-http-client index)
uri
:method :head
:force-binary binary-p)
(declare (ignore content))
(when (= code 404)
(cerror "Continue" 'index-object-missing :index index :path path))
(when (>= code 400)
(error "Unknown error!"))
(setf size (assoc-value headers :content-length))
(setf accept-ranges (assoc-value headers :accept-ranges))
(setf last-modified (parse-date-time (assoc-value headers :last-modified)))
(when (and signal-if-older-than
(< last-modified signal-if-older-than))
(signal 'index-object-out-of-date
:index index
:path path
:universal-time last-modified)))
(when (and offset (equal accept-ranges "bytes"))
;; Server supports range requests!
(push (cons :range (format nil "bytes=~D-~D" offset size)) headers))
(when (and offset (plusp offset))
(multiple-value-bind (content code headers)
(http-client-request (http-index-http-client index)
uri
:method :head
:force-binary binary-p)
(declare (ignore content))
;;(format t "~S~%" headers)
(when (= code 404)
(cerror "Continue" 'index-object-missing :index index :path path))
(when (>= code 400)
(error "Unknown error!"))
(setf size (assoc-value headers :content-length))
(setf accept-ranges (assoc-value headers :accept-ranges))
(setf last-modified (parse-date-time (assoc-value headers :last-modified)))
(when (and signal-if-older-than
(< last-modified signal-if-older-than))
(signal 'index-object-out-of-date
:index index
:path path
:universal-time last-modified)))
(when (equal accept-ranges "bytes")
(when (= offset (parse-integer size))
(return-from open-index-object-stream (make-concatenated-stream)))
;; Server supports range requests!
(push (cons :range (format nil "bytes=~D-~D" offset size)) headers)))
(multiple-value-bind (s code)
(http-client-request (http-index-http-client index) uri
:additional-headers headers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment