Skip to content

Instantly share code, notes, and snippets.

@steveyen
Created September 7, 2011 17:00
Show Gist options
  • Select an option

  • Save steveyen/1201110 to your computer and use it in GitHub Desktop.

Select an option

Save steveyen/1201110 to your computer and use it in GitHub Desktop.

Revisions

  1. Steve Yen revised this gist Sep 7, 2011. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,6 @@ class MyHTTP < Net::HTTP
    end
    end

    a = Time.now

    MyHTTP.new(host, port).start do |http|
    for x in 0..n
    req = Net::HTTP::Get.new("http://#{host}:#{port}/rest/of/url")
  2. Steve Yen created this gist Sep 7, 2011.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    class MyHTTP < Net::HTTP
    def on_connect()
    @socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
    end
    end

    a = Time.now

    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