Class: Vertx::HttpClientResponse
- Inherits:
-
Object
- Object
- Vertx::HttpClientResponse
- Includes:
- ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb
Overview
Vert.x provides you with one of these via the handler that was provided when creating the HttpClientRequest or that was set on the HttpClientRequest instance.
It implements ReadStream so it can be used with Pump to pump data with flow control.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) body { ... }
Same as #body but with an handler called when the operation completes.
-
- (self) body_handler { ... }
Convenience method for receiving the entire request body in one piece.
-
- (Array<String>) cookies
The Set-Cookie headers (including trailers).
-
- (self) custom_frame_handler { ... }
Set an custom frame handler.
- - (self) end_handler { ... }
- - (self) exception_handler { ... }
- - (self) fetch(amount = nil)
-
- (String) get_header(headerName = nil)
Return the first header value with the specified name.
-
- (String) get_trailer(trailerName = nil)
Return the first trailer value with the specified name.
- - (self) handler { ... }
-
- (::Vertx::MultiMap) headers
The headers.
-
- (::Vertx::NetSocket) net_socket
Get a net socket for the underlying connection of this request.
- - (self) pause
-
- (::Vertx::Pipe) pipe
Pause this stream and return a to transfer the elements of this stream to a destination .
-
- (void) pipe_to(dst = nil) { ... }
Pipe this ReadStream to the WriteStream.
-
- (::Vertx::HttpClientRequest) request
The corresponding request.
- - (self) resume
-
- (Fixnum) status_code
The status code of the response.
-
- (String) status_message
The status message of the response.
-
- (self) stream_priority_handler { ... }
Set an handler for stream priority changes.
-
- (::Vertx::MultiMap) trailers
The trailers.
-
- (:HTTP_1_0, ...) version
The version of the response.
Class Method Details
+ (Boolean) accept?(obj)
33 34 35 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 33 def @@j_api_type.accept?(obj) obj.class == HttpClientResponse end |
+ (Object) j_api_type
42 43 44 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 42 def self.j_api_type @@j_api_type end |
+ (Object) j_class
45 46 47 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 45 def self.j_class Java::IoVertxCoreHttp::HttpClientResponse.java_class end |
+ (Object) unwrap(obj)
39 40 41 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 39 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
36 37 38 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 36 def @@j_api_type.wrap(obj) HttpClientResponse.new(obj) end |
Instance Method Details
- (self) body { ... }
handler called when the operation completes
210 211 212 213 214 215 216 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 210 def body if true @j_del.java_method(:body, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Buffer) : nil) } unless !block_given?)) return self end raise ArgumentError, "Invalid arguments when calling body()" end |
- (self) body_handler { ... }
This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.
200 201 202 203 204 205 206 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 200 def body_handler if true @j_del.java_method(:bodyHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling body_handler()" end |
- (Array<String>) cookies
185 186 187 188 189 190 191 192 193 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 185 def if !block_given? if @cached_cookies != nil return @cached_cookies end return @cached_cookies = @j_del.java_method(:cookies, []).call().to_a.map { |elt| elt } end raise ArgumentError, "Invalid arguments when calling cookies()" end |
- (self) custom_frame_handler { ... }
221 222 223 224 225 226 227 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 221 def custom_frame_handler if true @j_del.java_method(:customFrameHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::HttpFrame)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling custom_frame_handler()" end |
- (self) end_handler { ... }
118 119 120 121 122 123 124 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 118 def end_handler if true @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield unless !block_given? }) return self end raise ArgumentError, "Invalid arguments when calling end_handler()" end |
- (self) exception_handler { ... }
92 93 94 95 96 97 98 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 92 def exception_handler if true @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (self) fetch(amount = nil)
75 76 77 78 79 80 81 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 75 def fetch(amount=nil) if amount.class == Fixnum && !block_given? @j_del.java_method(:fetch, [Java::long.java_class]).call(amount) return self end raise ArgumentError, "Invalid arguments when calling fetch(#{amount})" end |
- (String) get_header(headerName = nil)
159 160 161 162 163 164 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 159 def get_header(headerName=nil) if headerName.class == String && !block_given? return @j_del.java_method(:getHeader, [Java::java.lang.String.java_class]).call(headerName) end raise ArgumentError, "Invalid arguments when calling get_header(#{headerName})" end |
- (String) get_trailer(trailerName = nil)
168 169 170 171 172 173 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 168 def get_trailer(trailerName=nil) if trailerName.class == String && !block_given? return @j_del.java_method(:getTrailer, [Java::java.lang.String.java_class]).call(trailerName) end raise ArgumentError, "Invalid arguments when calling get_trailer(#{trailerName})" end |
- (self) handler { ... }
101 102 103 104 105 106 107 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 101 def handler if true @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer)) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (::Vertx::MultiMap) headers
147 148 149 150 151 152 153 154 155 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 147 def headers if !block_given? if @cached_headers != nil return @cached_headers end return @cached_headers = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headers, []).call(),::Vertx::MultiMap) end raise ArgumentError, "Invalid arguments when calling headers()" end |
- (::Vertx::NetSocket) net_socket
USE THIS WITH CAUTION! Writing to the socket directly if you don't know what you're doing can easily break the HTTP protocol.
HTTP/1.1 pipe-lined requests cannot support net socket upgrade.
One valid use-case for calling this is to receive the NetSocket after a HTTP CONNECT was issued to the remote peer and it responded with a status code of 200.
237 238 239 240 241 242 243 244 245 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 237 def net_socket if !block_given? if @cached_net_socket != nil return @cached_net_socket end return @cached_net_socket = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:netSocket, []).call(),::Vertx::NetSocket) end raise ArgumentError, "Invalid arguments when calling net_socket()" end |
- (self) pause
109 110 111 112 113 114 115 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 109 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (::Vertx::Pipe) pipe
WriteStream.
52 53 54 55 56 57 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 52 def pipe if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:pipe, []).call(),::Vertx::Pipe,::Vertx::Buffer.j_api_type) end raise ArgumentError, "Invalid arguments when calling pipe()" end |
- (void) pipe_to(dst = nil) { ... }
This method returns an undefined value.
Pipe thisReadStream to the WriteStream.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler will be
called with the result.
67 68 69 70 71 72 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 67 def pipe_to(dst=nil) if dst.class.method_defined?(:j_del) && true return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::IoVertxCore::Handler.java_class]).call(dst.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?)) end raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})" end |
- (::Vertx::HttpClientRequest) request
247 248 249 250 251 252 253 254 255 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 247 def request if !block_given? if @cached_request != nil return @cached_request end return @cached_request = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:request, []).call(),::Vertx::HttpClientRequest) end raise ArgumentError, "Invalid arguments when calling request()" end |
- (self) resume
83 84 85 86 87 88 89 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 83 def resume if !block_given? @j_del.java_method(:resume, []).call() return self end raise ArgumentError, "Invalid arguments when calling resume()" end |
- (Fixnum) status_code
133 134 135 136 137 138 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 133 def status_code if !block_given? return @j_del.java_method(:statusCode, []).call() end raise ArgumentError, "Invalid arguments when calling status_code()" end |
- (String) status_message
140 141 142 143 144 145 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 140 def if !block_given? return @j_del.java_method(:statusMessage, []).call() end raise ArgumentError, "Invalid arguments when calling status_message()" end |
- (self) stream_priority_handler { ... }
261 262 263 264 265 266 267 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 261 def stream_priority_handler if true @j_del.java_method(:streamPriorityHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) unless !block_given? })) return self end raise ArgumentError, "Invalid arguments when calling stream_priority_handler()" end |
- (::Vertx::MultiMap) trailers
175 176 177 178 179 180 181 182 183 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 175 def trailers if !block_given? if @cached_trailers != nil return @cached_trailers end return @cached_trailers = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:trailers, []).call(),::Vertx::MultiMap) end raise ArgumentError, "Invalid arguments when calling trailers()" end |
- (:HTTP_1_0, ...) version
126 127 128 129 130 131 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 126 def version if !block_given? return @j_del.java_method(:version, []).call().name.intern end raise ArgumentError, "Invalid arguments when calling version()" end |