How to get a segment of file on http, in Clojure using libraries like
clj-http or http-kit?
To get a portion of a file on a http server, one can send a GET message
with range headers -- well assume you know the server supports that. To
implement this in Java code, I know can use Java's HttpURLConnection api
or Apache's HttpClient library, so technically I can do that in Clojure
too, using Java interop. However, I want to implement this in a Clojure
way. People on SO recommended me using Clojure libraries like clj-http or
http-kit, since these provide more Clojure-like apis.
I have searched on documentations of both libraries, and google as well,
but I couldn't find any information about sending range headers with GET
message. I wonder if these libraries even support that functionality or
not.
I also tried to guess the usage by sending these code to the REPL, but
none of them was working:
>(client/get link {:range [0 9]})
;; the server sent me response message with whole file, not the bytes from
0 to 9
>(client/get link {:range 0-99})
;; just didn't work; got error from REPL
Anybody know how to do that with these libraries?
No comments:
Post a Comment