Added sign-blob-request overload for default get request

This commit is contained in:
Hugo Duncan 2010-09-19 11:15:22 -04:00
parent b7307add04
commit af094f6ffe
2 changed files with 11 additions and 2 deletions

View File

@ -241,11 +241,14 @@ Options can also be specified for extension modules
(defn sign-blob-request (defn sign-blob-request
"Get a signed http request for manipulating a blob in another application. "Get a signed http request for manipulating a blob in another application.
ex. curl. ex. curl. The default is for a :get request.
The request argument is used to specify charecteristics of the request The request argument is used to specify charecteristics of the request
to be signed. The :method key must be set to one of :get, :delete, and to be signed. The :method key must be set to one of :get, :delete, and
:put. For :put requests, :content-length must be specified. Optionally, :put. For :put requests, :content-length must be specified. Optionally,
:content-type and content-md5 may be given." :content-type, :content-disposition, :content-language, :content-encoding
and :content-md5 may be given."
([container-name path]
(sign-blob-request container-name path {:method :get} *blobstore*))
([container-name path ([container-name path
{:keys [method content-type content-length content-md5 {:keys [method content-type content-length content-md5
content-disposition content-encoding content-language] :as request}] content-disposition content-encoding content-language] :as request}]

View File

@ -112,9 +112,15 @@
(deftest sign-blob-request-test (deftest sign-blob-request-test
(testing "delete" (testing "delete"
(let [request (sign-blob-request "container" "path" {:method :delete})] (let [request (sign-blob-request "container" "path" {:method :delete})]
(is (= "http://localhost/container/path" (str (.getEndpoint request))))
(is (= "DELETE" (.getMethod request))))) (is (= "DELETE" (.getMethod request)))))
(testing "default request"
(let [request (sign-blob-request "container" "path")]
(is (= "http://localhost/container/path" (str (.getEndpoint request))))
(is (= "GET" (.getMethod request)))))
(testing "get" (testing "get"
(let [request (sign-blob-request "container" "path" {:method :get})] (let [request (sign-blob-request "container" "path" {:method :get})]
(is (= "http://localhost/container/path" (str (.getEndpoint request))))
(is (= "GET" (.getMethod request))))) (is (= "GET" (.getMethod request)))))
(testing "put" (testing "put"
(let [request (sign-blob-request (let [request (sign-blob-request