varnisher 1.0.beta.5 → 1.0.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/varnisher/purger.rb +24 -18
- data/lib/varnisher/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d5aa5c1be2b85a10cf504fb130b5da56a33c421
|
4
|
+
data.tar.gz: 13a2bf334f86a05098a4b0d4d2d370bccd305eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982f22d9f45952e2a95833771021e9c49bf9ef12af28b1f2e3df606eca4dd18788bbb571417ecdde3b048149e531544925ba9d14f92664f65e427172c5a4ea94
|
7
|
+
data.tar.gz: d747e97e01ade3036ac271394658f4858be492f8ac310e26ae5484b17fffed7950c78e4a0f99c6d5580c5c6d963998a598cdd4db1b2ad021bfb28a51a34eb209
|
data/lib/varnisher/purger.rb
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module Varnisher
|
2
|
+
module HTTP
|
3
|
+
# Adds the custom verb "PURGE" to the Net::HTTP library, allowing calls
|
4
|
+
# to:
|
5
|
+
#
|
6
|
+
# Net::HTTP.new(host, port).request(Varnisher::HTTP::Purge.new(uri))
|
7
|
+
class Purge < Net::HTTPRequest
|
8
|
+
METHOD = "PURGE"
|
9
|
+
REQUEST_HAS_BODY = false
|
10
|
+
RESPONSE_HAS_BODY = false
|
11
|
+
end
|
10
12
|
|
11
|
-
# Adds the custom verb "DOMAINPURGE" to the Net::HTTP library, allowing
|
12
|
-
# calls to:
|
13
|
-
#
|
14
|
-
# Net::HTTP.new(host, port).request(DomainPurge.new(uri))
|
15
|
-
class DomainPurge < Net::HTTPRequest
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
# Adds the custom verb "DOMAINPURGE" to the Net::HTTP library, allowing
|
14
|
+
# calls to:
|
15
|
+
#
|
16
|
+
# Net::HTTP.new(host, port).request(Varnisher::HTTP::DomainPurge.new(uri))
|
17
|
+
class DomainPurge < Net::HTTPRequest
|
18
|
+
METHOD = "DOMAINPURGE"
|
19
|
+
REQUEST_HAS_BODY = false
|
20
|
+
RESPONSE_HAS_BODY = false
|
21
|
+
end
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
module Varnisher
|
@@ -54,7 +58,7 @@ module Varnisher
|
|
54
58
|
# use "/"
|
55
59
|
# @param host [String] The hostname of the URL being purged
|
56
60
|
def initialize(method, path, host)
|
57
|
-
@request_method = method == "PURGE" ? Purge : DomainPurge
|
61
|
+
@request_method = method == "PURGE" ? Varnisher::HTTP::Purge : Varnisher::HTTP::DomainPurge
|
58
62
|
@path = path
|
59
63
|
@host = host
|
60
64
|
end
|
@@ -73,6 +77,8 @@ module Varnisher
|
|
73
77
|
hostname = Varnisher.options['hostname'] || @host
|
74
78
|
port = Varnisher.options['port']
|
75
79
|
|
80
|
+
@path = '/' if @path.nil? || @path == ''
|
81
|
+
|
76
82
|
begin
|
77
83
|
http = Net::HTTP.new(hostname, port)
|
78
84
|
response = http.request(@request_method.new(@path))
|
data/lib/varnisher/version.rb
CHANGED