Created
February 25, 2020 01:47
-
-
Save BMorearty/80427e4c14275963124560cfd97bb889 to your computer and use it in GitHub Desktop.
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 'async' | |
require 'kernel/sync' | |
require 'async/http' | |
require 'protocol/http' | |
endpoint = Async::HTTP::Endpoint.new(URI.parse('https://www.airbnb.com')) | |
client = Async::HTTP::Client.new(endpoint) | |
request = Protocol::HTTP::Request['GET', '/help/home', Protocol::HTTP::Headers[{}], nil] | |
Sync do | |
5.times do |i| | |
Async do | |
response = client.call(request) | |
body = response.read | |
puts "/help/home #{i}: status #{response.status}, sample: #{body.split("\n").grep(/doctype/i)[0]}" | |
end | |
end | |
end |
Author
BMorearty
commented
Feb 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment