Commit ea2dd421 authored by Eric Timmons's avatar Eric Timmons
Browse files

Be a little smarter about requesting HTTP offsets

parent 0958403d
Loading
Loading
Loading
Loading
+26 −22
Original line number Diff line number Diff line
@@ -55,12 +55,14 @@
        (accept-ranges)
        headers
        (last-modified))
    (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)
@@ -74,9 +76,11 @@
                  :index index
                  :path path
                  :universal-time last-modified)))
    (when (and offset (equal accept-ranges "bytes"))
      (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))
        (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