Skip to content

Instantly share code, notes, and snippets.

@cheald
Created January 2, 2013 16:30
Show Gist options
  • Save cheald/4435861 to your computer and use it in GitHub Desktop.
Save cheald/4435861 to your computer and use it in GitHub Desktop.
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