Class: Vertx::HttpClientResponse
- Inherits:
-
Object
- Object
- Vertx::HttpClientResponse
- Includes:
- ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/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.
Instance Method Summary (collapse)
-
- (self) body_handler { ... }
Convenience method for receiving the entire request body in one piece.
-
- (Array<String>) cookies
@return the Set-Cookie headers (including trailers).
- - (self) end_handler { ... }
- - (self) exception_handler { ... }
-
- (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
@return the headers.
-
- (::Vertx::NetSocket) net_socket
Get a net socket for the underlying connection of this request.
- - (self) pause
- - (self) resume
-
- (Fixnum) status_code
@return the status code of the response.
-
- (String) status_message
@return the status message of the response.
-
- (::Vertx::MultiMap) trailers
@return the trailers.
Instance Method Details
- (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.
143 144 145 146 147 148 149 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 143 def body_handler if block_given? @j_del.java_method(:bodyHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Buffer.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling body_handler()" end |
- (Array<String>) cookies
128 129 130 131 132 133 134 135 136 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 128 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) end_handler { ... }
63 64 65 66 67 68 69 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 63 def end_handler if block_given? @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield }) return self end raise ArgumentError, "Invalid arguments when calling end_handler()" end |
- (self) exception_handler { ... }
37 38 39 40 41 42 43 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 37 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event) })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (String) get_header(headerName = nil)
100 101 102 103 104 105 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 100 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)
109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 109 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 { ... }
46 47 48 49 50 51 52 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 46 def handler if block_given? @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Buffer.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (::Vertx::MultiMap) headers
88 89 90 91 92 93 94 95 96 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 88 def headers if !block_given? if @cached_headers != nil return @cached_headers end return @cached_headers = ::Vertx::MultiMap.new(@j_del.java_method(:headers, []).call()) 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
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.
157 158 159 160 161 162 163 164 165 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 157 def net_socket if !block_given? if @cached_net_socket != nil return @cached_net_socket end return @cached_net_socket = ::Vertx::NetSocket.new(@j_del.java_method(:netSocket, []).call()) end raise ArgumentError, "Invalid arguments when calling net_socket()" end |
- (self) pause
54 55 56 57 58 59 60 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 54 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (self) resume
28 29 30 31 32 33 34 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 28 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
72 73 74 75 76 77 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 72 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
80 81 82 83 84 85 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 80 def if !block_given? return @j_del.java_method(:statusMessage, []).call() end raise ArgumentError, "Invalid arguments when calling status_message()" end |
- (::Vertx::MultiMap) trailers
117 118 119 120 121 122 123 124 125 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_client_response.rb', line 117 def trailers if !block_given? if @cached_trailers != nil return @cached_trailers end return @cached_trailers = ::Vertx::MultiMap.new(@j_del.java_method(:trailers, []).call()) end raise ArgumentError, "Invalid arguments when calling trailers()" end |