[bknr-cvs] hans changed trunk/thirdparty/drakma/

BKNR Commits bknr at bknr.net
Mon Feb 7 17:27:24 UTC 2011


Revision: 4642
Author: hans
URL: http://bknr.net/trac/changeset/4642

support Range: header to retrieve partial resources
U   trunk/thirdparty/drakma/doc/index.html
U   trunk/thirdparty/drakma/request.lisp

Modified: trunk/thirdparty/drakma/doc/index.html
===================================================================
--- trunk/thirdparty/drakma/doc/index.html	2011-02-05 07:45:59 UTC (rev 4641)
+++ trunk/thirdparty/drakma/doc/index.html	2011-02-07 17:27:23 UTC (rev 4642)
@@ -731,7 +731,55 @@
 
 <!-- Entry for HTTP-REQUEST -->
 
-<p><br><table border=0><tr><td colspan=4 valign=top>[Function]</td></tr><tr><td valign=top style="white-space:nowrap"><a class=none name='http-request'><b>http-request</b></a> </td><td valign=top><i><a class=none href="#uri">uri</a> </i></td><td valign=top><tt>&key</tt> </td><td><i><a class=none href="#protocol">protocol</a> <a class=none href="#method">method</a> <a class=none href="#force-ssl">force-ssl</a> <a class=none href="#parameters">parameters</a> <a class=none href="#form-data">form-data</a> <a class=none href="#content">content</a> <a class=none href="#content-length">content-length</a> <a class=none href="#content-type">content-type</a> <a class=none href="#cookie-jar-param">cookie-jar</a> <a class=none href="#basic-authorization">basic-authorization</a> <a class=none href="#user-agent">user-agent</a> <a class=none href="#accept">accept</a> <a class=none href="#proxy">proxy</a> <a class=none href="#proxy-basic-authorization">proxy-basic-authorization</a> <a class=none href="#additional-headers">additional-headers</a> <a class=none href="#redirect">redirect</a> <a class=none href="#redirect-methods">redirect-methods</a> <a class=none href="#auto-referer">auto-referer</a> <a class=none href="#keep-alive">keep-alive</a> <a class=none href="#close">close</a> <a class=none href="#external-format-out">external-format-out</a> <a class=none href="#external-format-in">external-format-in</a> <a class=none href="#force-binary">force-binary</a> <a class=none href="#want-stream">want-stream</a> <a class=none href="#stream">stream</a> <a class=none href="#connection-timeout">connection-timeout</a> <a class=none href="#read-timeout">read-timeout</a> <a class=none href="#write-timeout">write-timeout</a> <a class=none href="#deadline">deadline</a></i></td></tr><tr><td colspan=2></td><td colspan=2 valign=top> => <i>body-or-stream, status-code, headers, uri, stream, <a class=none href="#must-close">must-close</a>, reason-phrase</i></td></tr></table>
+<p>
+  <br>
+  <table border=0>
+    <tr>
+      <td colspan=4 valign=top>[Function]</td>
+    </tr>
+    <tr>
+      <td valign=top style="white-space:nowrap"><a class=none name='http-request'><b>http-request</b></a> </td>
+      <td valign=top><i><a class=none href="#uri">uri</a> </i></td>
+      <td valign=top><tt>&key</tt> </td>
+      <td>
+        <i>
+          <a class=none href="#protocol">protocol</a>
+          <a class=none href="#method">method</a>
+          <a class=none href="#force-ssl">force-ssl</a>
+          <a class=none href="#parameters">parameters</a>
+          <a class=none href="#form-data">form-data</a>
+          <a class=none href="#content">content</a>
+          <a class=none href="#content-length">content-length</a>
+          <a class=none href="#content-type">content-type</a>
+          <a class=none href="#cookie-jar-param">cookie-jar</a>
+          <a class=none href="#basic-authorization">basic-authorization</a>
+          <a class=none href="#user-agent">user-agent</a>
+          <a class=none href="#accept">accept</a>
+          <a class=none href="#range">range</a>
+          <a class=none href="#proxy">proxy</a>
+          <a class=none href="#proxy-basic-authorization">proxy-basic-authorization</a>
+          <a class=none href="#additional-headers">additional-headers</a>
+          <a class=none href="#redirect">redirect</a>
+          <a class=none href="#redirect-methods">redirect-methods</a>
+          <a class=none href="#auto-referer">auto-referer</a>
+          <a class=none href="#keep-alive">keep-alive</a>
+          <a class=none href="#close">close</a>
+          <a class=none href="#external-format-out">external-format-out</a>
+          <a class=none href="#external-format-in">external-format-in</a>
+          <a class=none href="#force-binary">force-binary</a>
+          <a class=none href="#want-stream">want-stream</a>
+          <a class=none href="#stream">stream</a>
+          <a class=none href="#connection-timeout">connection-timeout</a>
+          <a class=none href="#read-timeout">read-timeout</a>
+          <a class=none href="#write-timeout">write-timeout</a>
+          <a class=none href="#deadline">deadline</a></i>
+      </td>
+    </tr>
+    <tr>
+      <td colspan=2></td>
+      <td colspan=2 valign=top> => <i>body-or-stream, status-code, headers, uri, stream, <a class=none href="#must-close">must-close</a>, reason-phrase</i></td>
+    </tr>
+  </table>
 <blockquote><br>
 
 Sends an <a href="http://www.rfc.net/rfc2616.html">HTTP</a> request to a web server and returns its reply.
@@ -935,6 +983,10 @@
 it can be a string which is used
 directly.  <a class=none name="accept"><code><i>accept</i></code></a>, if not <code>NIL</code>, is the
 'Accept' header sent - the default is <code>"*/*"</code>.
+<a class=none name="range"><code><i>range</i></code></a> optionally
+specifies a subrange of the resource to be requested.  It must be
+specified as list of two integers which indicate the start and
+(inclusive) end offset of the requested range, in bytes
 <p>
 If <a class=none name="proxy"><code><i>proxy</i></code></a> is not <code>NIL</code>, it should be a
 string denoting

Modified: trunk/thirdparty/drakma/request.lisp
===================================================================
--- trunk/thirdparty/drakma/request.lisp	2011-02-05 07:45:59 UTC (rev 4641)
+++ trunk/thirdparty/drakma/request.lisp	2011-02-07 17:27:23 UTC (rev 4642)
@@ -190,6 +190,7 @@
                               basic-authorization
                               (user-agent :drakma)
                               (accept "*/*")
+                              range
                               proxy
                               proxy-basic-authorization
                               additional-headers
@@ -314,9 +315,15 @@
 which denote the current version of Drakma or, in the latter four
 cases, a fixed string corresponding to a more or less recent \(as
 of August 2006) version of the corresponding browser.  Or it can
-be a string which is used directly.  ACCEPT, if not NIL, is the
-`Accept' header sent.
+be a string which is used directly.
 
+ACCEPT, if not NIL, specifies the contents of the `Accept' header
+sent.
+
+RANGE optionally specifies a subrange of the resource to be requested.
+It must be specified as list of two integers which indicate the start
+and (inclusive) end offset of the requested range, in bytes.
+
 If PROXY is not NIL, it should be a string denoting a proxy
 server through which the request should be sent.  Or it can be a
 list of two values - a string denoting the proxy server and an
@@ -404,6 +411,12 @@
     (parameter-error "CLOSE and KEEP-ALIVE must not be both true."))
   (when (and form-data (not (eq method :post)))
     (parameter-error "FORM-DATA makes only sense with POST requests."))
+  (when range
+    (unless (and (listp range)
+                 (integerp (first range))
+                 (integerp (second range))
+                 (<= (first range) (second range)))
+      (parameter-error "RANGE parameter must be specified as list of two integers, with the second larger or equal to the first")))
   ;; convert PROXY argument to canonical form
   (when proxy
     (when (atom proxy)
@@ -558,6 +571,8 @@
                                        (second proxy-basic-authorization)))))
               (when accept
                 (write-header "Accept" "~A" accept))
+              (when range
+                (write-header "Range" "bytes ~A-~A" (first range) (second range)))
               (when cookie-jar
                 ;; write all cookies in one fell swoop, so even Sun's
                 ;; web server has a chance to get it





More information about the Bknr-cvs mailing list