Class: Vertx::HttpServerRequest
- Inherits:
-
Object
- Object
- Vertx::HttpServerRequest
- Includes:
- ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb
Overview
Instances are created for each request and passed to the user via a handler.
Each instance of this class is associated with a corresponding HttpServerResponse instance via #response.
It implements ReadStream so it can be used with Pump to pump data with flow control.
Instance Method Summary (collapse)
-
- (String) absolute_uri
@return the absolute URI corresponding to the the HTTP request.
-
- (self) body_handler { ... }
Convenience method for receiving the entire request body in one piece.
- - (self) end_handler { ... }
-
- (true, false) ended?
Has the request ended? I.e.
- - (self) exception_handler { ... }
-
- (true, false) expect_multipart?
@return true if we are expecting a multi-part body for this request.
-
- (::Vertx::MultiMap) form_attributes
Returns a map of all form attributes in the request.
-
- (String) get_form_attribute(attributeName = nil)
Return the first form attribute value with the specified name.
-
- (String) get_header(headerName = nil)
Return the first header value with the specified name.
-
- (String) get_param(paramName = nil)
Return the first param value with the specified name.
- - (self) handler { ... }
-
- (::Vertx::MultiMap) headers
@return the headers in the request.
-
- (::Vertx::SocketAddress) local_address
@return the local (server side) address of the server that handles the request.
-
- (:OPTIONS, ...) method
@return the HTTP method for the request.
-
- (::Vertx::NetSocket) net_socket
Get a net socket for the underlying connection of this request.
-
- (::Vertx::MultiMap) params
@return the query parameters in the request.
-
- (String) path
@return The path part of the uri.
- - (self) pause
-
- (String) query
@return the query part of the uri.
-
- (::Vertx::SocketAddress) remote_address
@return the remote (client side) address of the request.
-
- (::Vertx::HttpServerResponse) response
@return the response.
- - (self) resume
-
- (self) set_expect_multipart(expect = nil)
Call this with true if you are expecting a multi-part body to be submitted in the request.
-
- (::Vertx::ServerWebSocket) upgrade
Upgrade the connection to a WebSocket connection.
-
- (self) upload_handler { ... }
Set an upload handler.
-
- (String) uri
@return the URI of the request.
-
- (:HTTP_1_0, :HTTP_1_1) version
@return the HTTP version of the request.
Instance Method Details
- (String) absolute_uri
192 193 194 195 196 197 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 192 def absolute_uri if !block_given? return @j_del.java_method(:absoluteURI, []).call() end raise ArgumentError, "Invalid arguments when calling absolute_uri()" end |
- (self) body_handler { ... }
This saves the user having to manually setting a data and end handler 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.
204 205 206 207 208 209 210 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 204 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 |
- (self) end_handler { ... }
69 70 71 72 73 74 75 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 69 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 |
- (true, false) ended?
296 297 298 299 300 301 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 296 def ended? if !block_given? return @j_del.java_method(:isEnded, []).call() end raise ArgumentError, "Invalid arguments when calling ended?()" end |
- (self) exception_handler { ... }
35 36 37 38 39 40 41 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 35 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 |
- (true, false) expect_multipart?
241 242 243 244 245 246 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 241 def expect_multipart? if !block_given? return @j_del.java_method(:isExpectMultipart, []).call() end raise ArgumentError, "Invalid arguments when calling expect_multipart?()" end |
- (::Vertx::MultiMap) form_attributes
Be aware that the attributes will only be available after the whole body has been received, i.e. after the request end handler has been called.
#set_expect_multipart must be called first before trying to get the form attributes.
265 266 267 268 269 270 271 272 273 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 265 def form_attributes if !block_given? if @cached_form_attributes != nil return @cached_form_attributes end return @cached_form_attributes = ::Vertx::MultiMap.new(@j_del.java_method(:formAttributes, []).call()) end raise ArgumentError, "Invalid arguments when calling form_attributes()" end |
- (String) get_form_attribute(attributeName = nil)
277 278 279 280 281 282 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 277 def get_form_attribute(attributeName=nil) if attributeName.class == String && !block_given? return @j_del.java_method(:getFormAttribute, [Java::java.lang.String.java_class]).call(attributeName) end raise ArgumentError, "Invalid arguments when calling get_form_attribute(attributeName)" end |
- (String) get_header(headerName = nil)
142 143 144 145 146 147 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 142 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_param(paramName = nil)
162 163 164 165 166 167 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 162 def get_param(paramName=nil) if paramName.class == String && !block_given? return @j_del.java_method(:getParam, [Java::java.lang.String.java_class]).call(paramName) end raise ArgumentError, "Invalid arguments when calling get_param(paramName)" end |
- (self) handler { ... }
44 45 46 47 48 49 50 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 44 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
130 131 132 133 134 135 136 137 138 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 130 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::SocketAddress) local_address
181 182 183 184 185 186 187 188 189 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 181 def local_address if !block_given? if @cached_local_address != nil return @cached_local_address end return @cached_local_address = ::Vertx::SocketAddress.new(@j_del.java_method(:localAddress, []).call()) end raise ArgumentError, "Invalid arguments when calling local_address()" end |
- (:OPTIONS, ...) method
86 87 88 89 90 91 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 86 def method if !block_given? return @j_del.java_method(:method, []).call().name.intern end raise ArgumentError, "Invalid arguments when calling method()" end |
- (::Vertx::NetSocket) net_socket
USE THIS WITH CAUTION!
Once you have called this method, you must handle writing to the connection yourself using the net socket, the server request instance will no longer be usable as normal. Writing to the socket directly if you don't know what you're doing can easily break the HTTP protocol.
219 220 221 222 223 224 225 226 227 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 219 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 |
- (::Vertx::MultiMap) params
150 151 152 153 154 155 156 157 158 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 150 def params if !block_given? if @cached_params != nil return @cached_params end return @cached_params = ::Vertx::MultiMap.new(@j_del.java_method(:params, []).call()) end raise ArgumentError, "Invalid arguments when calling params()" end |
- (String) path
102 103 104 105 106 107 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 102 def path if !block_given? return @j_del.java_method(:path, []).call() end raise ArgumentError, "Invalid arguments when calling path()" end |
- (self) pause
52 53 54 55 56 57 58 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 52 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (String) query
110 111 112 113 114 115 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 110 def query if !block_given? return @j_del.java_method(:query, []).call() end raise ArgumentError, "Invalid arguments when calling query()" end |
- (::Vertx::SocketAddress) remote_address
170 171 172 173 174 175 176 177 178 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 170 def remote_address if !block_given? if @cached_remote_address != nil return @cached_remote_address end return @cached_remote_address = ::Vertx::SocketAddress.new(@j_del.java_method(:remoteAddress, []).call()) end raise ArgumentError, "Invalid arguments when calling remote_address()" end |
- (::Vertx::HttpServerResponse) response
119 120 121 122 123 124 125 126 127 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 119 def response if !block_given? if @cached_response != nil return @cached_response end return @cached_response = ::Vertx::HttpServerResponse.new(@j_del.java_method(:response, []).call()) end raise ArgumentError, "Invalid arguments when calling response()" end |
- (self) resume
60 61 62 63 64 65 66 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 60 def resume if !block_given? @j_del.java_method(:resume, []).call() return self end raise ArgumentError, "Invalid arguments when calling resume()" end |
- (self) set_expect_multipart(expect = nil)
232 233 234 235 236 237 238 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 232 def set_expect_multipart(expect=nil) if (expect.class == TrueClass || expect.class == FalseClass) && !block_given? @j_del.java_method(:setExpectMultipart, [Java::boolean.java_class]).call(expect) return self end raise ArgumentError, "Invalid arguments when calling set_expect_multipart(expect)" end |
- (::Vertx::ServerWebSocket) upgrade
This is an alternative way of handling WebSockets and can only be used if no websocket handlers are set on the Http server, and can only be used during the upgrade request during the WebSocket handshake.
288 289 290 291 292 293 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 288 def upgrade if !block_given? return ::Vertx::ServerWebSocket.new(@j_del.java_method(:upgrade, []).call()) end raise ArgumentError, "Invalid arguments when calling upgrade()" end |
- (self) upload_handler { ... }
251 252 253 254 255 256 257 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 251 def upload_handler if block_given? @j_del.java_method(:uploadHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::HttpServerFileUpload.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling upload_handler()" end |
- (String) uri
94 95 96 97 98 99 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 94 def uri if !block_given? return @j_del.java_method(:uri, []).call() end raise ArgumentError, "Invalid arguments when calling uri()" end |
- (:HTTP_1_0, :HTTP_1_1) version
78 79 80 81 82 83 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/http_server_request.rb', line 78 def version if !block_given? return @j_del.java_method(:version, []).call().name.intern end raise ArgumentError, "Invalid arguments when calling version()" end |