0
我正在嘗試使用'路邊'寶石向我們的清漆盒發送「PURGE」請求,問題在於它似乎無法正常工作。嘗試'PURGE'使用路緣清漆
我不知道它是否因爲沒有在我們的清漆盒中實現而失敗(它應該是)或者因爲路緣沒有發送請求作爲清除,而是作爲get。
下面是實際發出請求的功能:
def make_request_of (request_method)
self.curl = Curl::Easy.new(self.uri) do |http|
setup_request request_method, http
end
self.curl.ssl_verify_peer = self.ssl ||false
self.curl.http request_method
if self.curl.response_code == 301
self.uri = self.curl.redirect_url
make_request_of request_method
end
end
def setup_request method,http
http.headers['request-method'] = method.to_s
http.headers.update(headers)
http.max_redirects = self.redirects || 3
http.post_body = self.payload || nil
http.http_auth_types = self.auth_type || nil
http.username = self.username || nil
http.password = self.password || nil
http.useragent = "curb"
http
end
運行時(有兩個漆箱IP)我得到這樣的:
- 真
with true
def flush pattern
results = ::YAML.load_file(self.varnish_ip_files_path).map do |ip|
http = VCK::Http.request do
set_uri "http://#{ip}/#{pattern}"
end
http.make_request_of 'PURGE'
puts http.response
case http.response
when 200
true
else
false
end
end
!(results.reject! { |r| r }.length >= 1)
end
我使用this answer發送「PURGE的要求嘗試,特別是:正在值這個函數返回
# see lib/curl.rb
module Curl
# ...
def self.patch(url, params={}, &block)
http :PATCH, url, postalize(params), nil, &block
end
# ...
end