Created
May 8, 2019 15:57
-
-
Save rezan/18d173519cf3374761e38a18b7225843 to your computer and use it in GitHub Desktop.
Body hashing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varnishtest "Test xbody hash large body" | |
server s1 { | |
rxreq | |
txresp -bodylen 500000 | |
} -start | |
varnish v1 -vcl+backend { | |
import crypto; | |
import xbody; | |
sub vcl_backend_response { | |
xbody.hash_body(md5, "1"); | |
xbody.hash_body(sha1, "2"); | |
xbody.hash_body(sha224, "3"); | |
xbody.hash_body(sha256, "4"); | |
xbody.hash_body(sha384, "5"); | |
xbody.hash_body(sha512, "6"); | |
} | |
sub vcl_deliver { | |
set resp.http.md5 = crypto.hex_encode(xbody.get_hash("1")); | |
set resp.http.sha1 = crypto.hex_encode(xbody.get_hash("2")); | |
set resp.http.sha224 = crypto.hex_encode(xbody.get_hash("3")); | |
set resp.http.sha256 = crypto.hex_encode(xbody.get_hash("4")); | |
set resp.http.sha384 = crypto.hex_encode(xbody.get_hash("5")); | |
set resp.http.sha512 = crypto.hex_encode(xbody.get_hash("6")); | |
set resp.http.all = xbody.get_all(); | |
} | |
} -start | |
client c1 { | |
txreq | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.md5 == "0d41ad89a500eff2c3dc89282808e041" | |
expect resp.http.sha1 == "64dcb263b6ec86a5d2cb78b6124ceddaa91054c6" | |
expect resp.http.sha224 == "b3a48c8595265f3b77c508186398e261848c462dd2e44040d5de5e94" | |
expect resp.http.sha256 == "1f1a678dd8711e36ed3d03ba927d6f37f892a1ea8129c9ea43d0273326d3327d" | |
expect resp.http.sha384 == "9219008df54bc6adfc55eb80c88d1cabb3c246b16964c3f56699a1d27677eee21d3ada211ac268bd67f08fb491e4f205" | |
expect resp.http.sha512 == "0666c44e993e541913d577f4465b4939f716bb608a21a74a629a807120240fa447630315773521b4b377c0474bf12010fd8891009c85ad6262bc9d973566ef93" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment