Created
September 7, 2011 17:00
-
-
Save steveyen/1201110 to your computer and use it in GitHub Desktop.
Using TCP_NODELAY with ruby Net HTTP
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
class MyHTTP < Net::HTTP | |
def on_connect() | |
@socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) | |
end | |
end | |
MyHTTP.new(host, port).start do |http| | |
for x in 0..n | |
req = Net::HTTP::Get.new("http://#{host}:#{port}/rest/of/url") | |
req.add_field('Connection', 'keep-alive') | |
http.request(req) do |res| | |
res.read_body | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment