Created
January 2, 2013 16:30
-
-
Save cheald/4435861 to your computer and use it in GitHub Desktop.
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
def purge(ip, port, domain, uri) | |
begin | |
socket = TCPSocket.new(ip, port) | |
socket.write "PURGE #{uri} HTTP/1.1\r\nX-Purge: #{uri}\r\nUser-Agent: ruby/socket\r\nAccept: */*\r\nHost: #{domain}\r\n\r\n" | |
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EHOSTUNREACH | |
# Nothing to do | |
ensure | |
socket.close if socket and !socket.closed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment