mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
pimping my examples
This commit is contained in:
parent
8d1f67d814
commit
3df3eba0fc
@ -3,7 +3,11 @@ require "httpx"
|
||||
include HTTPX
|
||||
|
||||
# supports HTTP/1 pipelining and HTTP/2
|
||||
URLS = %w[https://nghttp2.org https://nghttp2.org/blog/]
|
||||
URLS = %w[http://nghttp2.org http://nghttp2.org/blog/] * 51
|
||||
|
||||
|
||||
# supports HTTP/2 and HTTP/1 Keep-Alive
|
||||
# URLS = %w[http://nghttp2.org/httpbin/] * 102
|
||||
#
|
||||
# supports HTTP/1 pipelining
|
||||
# URLS = %w[https://github.com https://github.com/blog]
|
||||
@ -13,6 +17,7 @@ client = Client.new
|
||||
requests = URLS.map { |url| client.request(:get, url) }
|
||||
responses = client.send(*requests)
|
||||
|
||||
#responses.each do |res|
|
||||
# puts "status: #{res.status}, length: #{res.body.to_s.bytesize}"
|
||||
#end
|
||||
puts responses.map(&:status)
|
||||
|
||||
client.close
|
||||
|
@ -3,7 +3,7 @@ require "json"
|
||||
|
||||
include HTTPX
|
||||
|
||||
URLS = %w[http://httpbin.org/post]
|
||||
URLS = %w[http://nghttp2.org/httpbin/post] * 102
|
||||
|
||||
$HTTPX_DEBUG = true
|
||||
client = Client.new
|
||||
@ -12,6 +12,7 @@ responses = client.send(*requests)
|
||||
|
||||
responses.each do |res|
|
||||
puts "status: #{res.status}"
|
||||
puts "headers: #{res.headers}"
|
||||
puts "body: #{JSON.parse(res.body.to_s)}"
|
||||
end
|
||||
# puts responses.map(&:status)
|
||||
|
Loading…
x
Reference in New Issue
Block a user