Module: Asap::Netty
- Defined in:
- lib/asap/netty.rb,
lib/asap/netty/pipeline_factory.rb,
lib/asap/netty/http_response_handler.rb
Defined Under Namespace
Classes: HttpResponseHandler, PipelineFactory
Class Method Summary collapse
Class Method Details
.get(url, &callback) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/asap/netty.rb', line 21 def self.get(url, &callback) uri = URI.parse(url) bootstrap.set_pipeline_factory(PipelineFactory.new(callback)) # Open a connection future = bootstrap.connect(InetSocketAddress.new(uri.host, uri.port)) channel = future.awaitUninterruptibly.get_channel raise 'connection failed' unless future.is_success # Send the request request = DefaultHttpRequest.new(HttpVersion::HTTP_1_0, HttpMethod::GET, uri.path) request.set_header(HttpHeaders::Names::HOST, uri.host) channel.write(request) end |