Created
March 24, 2013 23:47
-
-
Save sentientmonkey/5234110 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
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| http = Net::HTTP.new('www.iana.org') | |
| http.set_debug_output $stderr | |
| http.start do |http| | |
| request = Net::HTTP::Get.new('/domains/example') | |
| response = http.request request | |
| end | |
| # opening connection to www.iana.org... | |
| # opened | |
| # <- "GET /domains/example HTTP/1.1\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: www.iana.org\r\n\r\n" | |
| # -> "HTTP/1.1 200 OK\r\n" | |
| # -> "Date: Sun, 24 Mar 2013 23:12:25 GMT\r\n" | |
| # -> "Server: Apache/2.2.3 (CentOS)\r\n" | |
| # -> "Last-Modified: Fri, 04 Jan 2013 01:17:22 GMT\r\n" | |
| # -> "Vary: Accept-Encoding\r\n" | |
| # -> "Connection: close\r\n" | |
| # -> "Transfer-Encoding: chunked\r\n" | |
| # -> "Content-Type: text/html; charset=UTF-8\r\n" | |
| # -> "\r\n" | |
| # -> "457\r\n" | |
| # reading 1111 bytes... | |
| # -> "<!doctype html>\n<html>\n<head>\n\t<title>Example Domain</title>\n\n\t<meta charset=\"utf-8\" />\n\t<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<style type=\"text/css\">\n\tbody {\n\t\tbackground-color: #f0f0f2;\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tfont-family: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n\t\t\n\t}\n\tdiv {\n\t\twidth: 600px;\n\t\tmargin: 5em auto;\n\t\tpadding: 3em;\n\t\tbackground-color: #fff;\n\t\tborder-radius: 1em;\n\t}\n\ta:link, a:visited {\n\t\tcolor: #38488f;\n\t\ttext-decoration: none;\n\t}\n\t@media (max-width: 600px) {\n\t\tbody {\n\t\t\tbackground-color: #fff;\n\t\t}\n\t\tdiv {\n\t\t\twidth: auto;\n\t\t\tmargin: 0 auto;\n\t\t\tborder-radius: 0;\n\t\t\tpadding: 1em;\n\t\t}\n\t}\n\t</style>\t\n</head>\n\n<body>\n<div>\n\t<h1>Example Domain</h1>\n\t<p>This domain is established to be used for illustrative examples in documents. You do not need to\n\t\tcoordinate or ask for permission to use this domain in examples, and it is not available for\n\t\tregistration.</p>\n\t<p><a href=\"http://www.iana.org/domains/special\">More information...</a></p>\n</div>\n</body>\n</html>\n" | |
| # read 1111 bytes | |
| # reading 2 bytes... | |
| # -> "\r\n" | |
| # read 2 bytes | |
| # -> "0\r\n" | |
| # -> "\r\n" | |
| # Conn close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment