Created
June 2, 2014 21:45
-
-
Save jakenotjacob/211806c8917f3f1fb78b to your computer and use it in GitHub Desktop.
Client used to test my HTTP server
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
#!/usr/bin/env ruby | |
# | |
require 'socket' | |
server, port, resource = ARGV | |
conn = TCPSocket.open server, port | |
conn.print("GET #{resource} HTTP/1.0\r\n\r\n") | |
response = conn.read | |
headers, body = response.split("\r\n\r\n", 2) | |
puts "---HEADERS---" | |
puts headers | |
puts "-------------" | |
puts "---BODY---" | |
puts body | |
puts "----------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment