Created
August 21, 2010 18:02
-
-
Save hukl/542647 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'openssl' | |
| require 'socket' | |
| header = <<HEADER | |
| GET / HTTP/1.1 | |
| Host: example.com | |
| Origin: localhost | |
| Content-Length: 0 | |
| Content-Type: text/plain | |
| Connection: close\r\n\r\n | |
| HEADER | |
| begin | |
| s = TCPSocket.open("example.com", 443) | |
| ssl_context = OpenSSL::SSL::SSLContext.new | |
| puts ssl_context.verify_mode | |
| s = OpenSSL::SSL::SSLSocket.new( s, ssl_context ) | |
| s.sync_close = true | |
| s.connect | |
| s.post_connection_check("example.com") | |
| s.write header | |
| puts s.read | |
| ensure | |
| s.close | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment