http 0.9.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -0
- data/CHANGES.md +143 -92
- data/Gemfile +4 -4
- data/README.md +8 -27
- data/lib/http/chainable.rb +13 -30
- data/lib/http/client.rb +17 -12
- data/lib/http/connection.rb +10 -7
- data/lib/http/errors.rb +3 -0
- data/lib/http/headers.rb +0 -3
- data/lib/http/options.rb +9 -12
- data/lib/http/request/writer.rb +14 -12
- data/lib/http/request.rb +23 -14
- data/lib/http/response/body.rb +7 -6
- data/lib/http/response/parser.rb +2 -1
- data/lib/http/response/status.rb +1 -3
- data/lib/http/response.rb +31 -28
- data/lib/http/timeout/global.rb +2 -1
- data/lib/http/timeout/null.rb +2 -1
- data/lib/http/timeout/per_operation.rb +2 -1
- data/lib/http/version.rb +1 -1
- data/lib/http.rb +0 -2
- data/logo.png +0 -0
- data/spec/lib/http/client_spec.rb +25 -16
- data/spec/lib/http/options/merge_spec.rb +3 -1
- data/spec/lib/http/options_spec.rb +2 -3
- data/spec/lib/http/redirector_spec.rb +39 -34
- data/spec/lib/http/request/writer_spec.rb +3 -3
- data/spec/lib/http/request_spec.rb +41 -7
- data/spec/lib/http/response/body_spec.rb +1 -1
- data/spec/lib/http/response/status_spec.rb +3 -3
- data/spec/lib/http/response_spec.rb +10 -1
- data/spec/lib/http_spec.rb +66 -7
- data/spec/spec_helper.rb +2 -2
- data/spec/support/connection_reuse_shared.rb +1 -1
- data/spec/support/dummy_server/servlet.rb +7 -0
- data/spec/support/http_handling_shared.rb +7 -1
- metadata +3 -4
- data/examples/parallel_requests_with_celluloid.rb +0 -38
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#
|
|
3
|
-
# Example of using the HTTP Gem with Celluloid::IO
|
|
4
|
-
# Make sure to 'gem install celluloid-io' before running
|
|
5
|
-
#
|
|
6
|
-
# Run as: bundle exec examples/parallel_requests_with_celluloid.rb
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
require "celluloid/io"
|
|
10
|
-
require "http"
|
|
11
|
-
|
|
12
|
-
class HttpFetcher
|
|
13
|
-
include Celluloid::IO
|
|
14
|
-
|
|
15
|
-
def fetch(url)
|
|
16
|
-
# Note: For SSL support specify:
|
|
17
|
-
# ssl_socket_class: Celluloid::IO::SSLSocket
|
|
18
|
-
HTTP.get(url, :socket_class => Celluloid::IO::TCPSocket)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
fetcher = HttpFetcher.new
|
|
23
|
-
|
|
24
|
-
urls = %w(http://ruby-lang.org/ http://rubygems.org/ http://celluloid.io/)
|
|
25
|
-
|
|
26
|
-
# Kick off a bunch of future calls to HttpFetcher to grab the URLs in parallel
|
|
27
|
-
futures = urls.map { |u| [u, fetcher.future.fetch(u)] }
|
|
28
|
-
|
|
29
|
-
# Consume the results as they come in
|
|
30
|
-
futures.each do |url, future|
|
|
31
|
-
# Wait for HttpFetcher#fetch to complete for this request
|
|
32
|
-
response = future.value
|
|
33
|
-
puts "Got #{url}: #{response.inspect}"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Suppress Celluloid's shutdown messages
|
|
37
|
-
# Otherwise the example is a bit noisy :|
|
|
38
|
-
exit!
|