Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow specification of a cookie in wait-for-http-status

  • Loading branch information...
commit 8879563cab4e2d69c828c9d2d44d8e01d56fa3a3 1 parent 10e4607
@hugoduncan hugoduncan authored
View
10 src/pallet/crate/network_service.clj
@@ -41,7 +41,7 @@
- :max-retries number of times to test HTTP status before erroring
- :url-name name of url to use in messages (defaults to url)"
- [session url status & {:keys [max-retries standoff url-name]
+ [session url status & {:keys [max-retries standoff url-name cookie]
:or {max-retries 5 standoff 2
url-name url}}]
(->
@@ -52,13 +52,17 @@
(if (~lib/has-command? wget)
(defn httpresponse []
(pipe
- ("wget" -q -S -O "/dev/null" (quoted ~url) "2>&1")
+ ("wget" -q -S -O "/dev/null"
+ ~(if cookie (str "--header " (format "'Cookie: %s'" cookie)) "")
+ (quoted ~url) "2>&1")
("grep" "HTTP/1.1")
("tail" -1)
("grep" -o -e (quoted "[0-9][0-9][0-9]"))))
(if (~lib/has-command? curl)
(defn httpresponse []
- ("curl" -sL -w (quoted "%{http_code}") (quoted ~url)
+ ("curl" -sL -w (quoted "%{http_code}")
+ ~(if cookie (str "-b '" cookie "'") "")
+ (quoted ~url)
-o "/dev/null"))
(do
(println "No httpresponse utility available")
View
14 test/pallet/crate/network_service_test.clj
@@ -16,4 +16,16 @@
(first
(build-actions/build-actions
{}
- (network-service/wait-for-http-status "http://localhost/" 200)))))
+ (network-service/wait-for-http-status "http://localhost/" 200))))
+ (re-find #"-b 'x=y'"
+ (first
+ (build-actions/build-actions
+ {}
+ (network-service/wait-for-http-status
+ "http://localhost/" 200 :cookie "x=y"))))
+ (re-find #"--header 'Cookie: x=y'"
+ (first
+ (build-actions/build-actions
+ {}
+ (network-service/wait-for-http-status
+ "http://localhost/" 200 :cookie "x=y")))))
Please sign in to comment.
Something went wrong with that request. Please try again.