Class: VertxWebClient::HttpRequest
- Inherits:
-
Object
- Object
- VertxWebClient::HttpRequest
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb
Overview
Instances are created by an WebClient instance, via one of the methods corresponding to the specific HTTP methods such as WebClient#get, etc...
The request shall be configured prior sending, the request is immutable and when a mutator method is called, a new request is returned allowing to expose the request in a public API and apply further customization.
After the request has been configured, the methods
can be called. ThesendXXX
methods perform the actual request, they can be called multiple times to perform the same HTTP
request at different points in time.
The handler is called back with
- an HttpResponse instance when the HTTP response has been received
- a failure when the HTTP request failed (like a connection error) or when the HTTP response could not be obtained (like connection or unmarshalling errors)
Most of the time, this client will buffer the HTTP response fully unless a specific is used such as .
Instance Method Summary (collapse)
-
- (self) add_query_param(paramName = nil, paramValue = nil)
Add a query parameter to the request.
-
- (::VertxWebClient::HttpRequest) as(responseCodec = nil)
Configure the request to decode the response with the responseCodec.
-
- (::VertxWebClient::HttpRequest) copy
Copy this request.
-
- (::Vertx::MultiMap) headers
The HTTP headers.
-
- (self) host(value = nil)
Configure the request to use a new host value.
-
- (self) method(value = nil)
Configure the request to use a new method value.
-
- (self) port(value = nil)
Configure the request to use a new port value.
-
- (self) put_header(name = nil, value = nil)
Configure the request to add a new HTTP header.
-
- (::Vertx::MultiMap) query_params
Return the current query parameters.
-
- (void) send { ... }
Send a request, the handler will receive the response as an HttpResponse.
-
- (void) send_buffer(body = nil) { ... }
Like #send but with an HTTP request body buffer.
-
- (void) send_form(body = nil) { ... }
Like #send but with an HTTP request body multimap encoded as form and the content type set to application/x-www-form-urlencoded.
-
- (void) send_json(body = nil) { ... }
Like #send but with an HTTP request body object encoded as json and the content type set to application/json.
-
- (void) send_json_object(body = nil) { ... }
Like #send but with an HTTP request body object encoded as json and the content type set to application/json.
-
- (void) send_stream(body = nil) { ... }
Like #send but with an HTTP request body stream.
-
- (self) set_query_param(paramName = nil, paramValue = nil)
Set a query parameter to the request.
-
- (self) timeout(value = nil)
Configures the amount of time in milliseconds after which if the request does not return any data within the timeout period an TimeoutException fails the request.
-
- (self) uri(value = nil)
Configure the request to use a new request URI value.
Instance Method Details
- (self) add_query_param(paramName = nil, paramValue = nil)
139 140 141 142 143 144 145 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 139 def add_query_param(paramName=nil,paramValue=nil) if paramName.class == String && paramValue.class == String && !block_given? @j_del.java_method(:addQueryParam, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(paramName,paramValue) return self end raise ArgumentError, "Invalid arguments when calling add_query_param(#{paramName},#{paramValue})" end |
- (::VertxWebClient::HttpRequest) as(responseCodec = nil)
responseCodec
.
72 73 74 75 76 77 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 72 def as(responseCodec=nil) if responseCodec.class.method_defined?(:j_del) && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:as, [Java::IoVertxExtWebCodec::BodyCodec.java_class]).call(responseCodec.j_del),::VertxWebClient::HttpRequest, nil) end raise ArgumentError, "Invalid arguments when calling as(#{responseCodec})" end |
- (::VertxWebClient::HttpRequest) copy
167 168 169 170 171 172 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 167 def copy if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:copy, []).call(),::VertxWebClient::HttpRequest, nil) end raise ArgumentError, "Invalid arguments when calling copy()" end |
- (::Vertx::MultiMap) headers
113 114 115 116 117 118 119 120 121 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 113 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 |
- (self) host(value = nil)
value
.
81 82 83 84 85 86 87 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 81 def host(value=nil) if value.class == String && !block_given? @j_del.java_method(:host, [Java::java.lang.String.java_class]).call(value) return self end raise ArgumentError, "Invalid arguments when calling host(#{value})" end |
- (self) method(value = nil)
value
.
52 53 54 55 56 57 58 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 52 def method(value=nil) if value.class == Symbol && !block_given? @j_del.java_method(:method, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(value.to_s)) return self end raise ArgumentError, "Invalid arguments when calling method(#{value})" end |
- (self) port(value = nil)
value
.
62 63 64 65 66 67 68 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 62 def port(value=nil) if value.class == Fixnum && !block_given? @j_del.java_method(:port, [Java::int.java_class]).call(value) return self end raise ArgumentError, "Invalid arguments when calling port(#{value})" end |
- (self) put_header(name = nil, value = nil)
105 106 107 108 109 110 111 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 105 def put_header(name=nil,value=nil) if name.class == String && value.class == String && !block_given? @j_del.java_method(:putHeader, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value) return self end raise ArgumentError, "Invalid arguments when calling put_header(#{name},#{value})" end |
- (::Vertx::MultiMap) query_params
159 160 161 162 163 164 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 159 def query_params if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:queryParams, []).call(),::Vertx::MultiMap) end raise ArgumentError, "Invalid arguments when calling query_params()" end |
- (void) send { ... }
This method returns an undefined value.
Send a request, thehandler
will receive the response as an VertxWebClient::HttpResponse.
231 232 233 234 235 236 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 231 def send if block_given? return @j_del.java_method(:send, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send()" end |
- (void) send_buffer(body = nil) { ... }
187 188 189 190 191 192 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 187 def send_buffer(body=nil) if body.class.method_defined?(:j_del) && block_given? return @j_del.java_method(:sendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(body.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_buffer(#{body})" end |
- (void) send_form(body = nil) { ... }
This method returns an undefined value.
Like #send but with an HTTP requestbody
multimap encoded as form and the content type
set to application/x-www-form-urlencoded
.
When the content type header is previously set to multipart/form-data
it will be used instead.
222 223 224 225 226 227 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 222 def send_form(body=nil) if body.class.method_defined?(:j_del) && block_given? return @j_del.java_method(:sendForm, [Java::IoVertxCore::MultiMap.java_class,Java::IoVertxCore::Handler.java_class]).call(body.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_form(#{body})" end |
- (void) send_json(body = nil) { ... }
This method returns an undefined value.
Like #send but with an HTTP requestbody
object encoded as json and the content type
set to application/json
.
209 210 211 212 213 214 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 209 def send_json(body=nil) if ::Vertx::Util::unknown_type.accept?(body) && block_given? return @j_del.java_method(:sendJson, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(body),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_json(#{body})" end |
- (void) send_json_object(body = nil) { ... }
This method returns an undefined value.
Like #send but with an HTTP requestbody
object encoded as json and the content type
set to application/json
.
198 199 200 201 202 203 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 198 def send_json_object(body=nil) if body.class == Hash && block_given? return @j_del.java_method(:sendJsonObject, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(body),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_json_object(#{body})" end |
- (void) send_stream(body = nil) { ... }
177 178 179 180 181 182 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 177 def send_stream(body=nil) if body.class.method_defined?(:j_del) && block_given? return @j_del.java_method(:sendStream, [Java::IoVertxCoreStreams::ReadStream.java_class,Java::IoVertxCore::Handler.java_class]).call(body.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_stream(#{body})" end |
- (self) set_query_param(paramName = nil, paramValue = nil)
150 151 152 153 154 155 156 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 150 def set_query_param(paramName=nil,paramValue=nil) if paramName.class == String && paramValue.class == String && !block_given? @j_del.java_method(:setQueryParam, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(paramName,paramValue) return self end raise ArgumentError, "Invalid arguments when calling set_query_param(#{paramName},#{paramValue})" end |
- (self) timeout(value = nil)
Setting zero or a negative value
disables the timeout.
128 129 130 131 132 133 134 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 128 def timeout(value=nil) if value.class == Fixnum && !block_given? @j_del.java_method(:timeout, [Java::long.java_class]).call(value) return self end raise ArgumentError, "Invalid arguments when calling timeout(#{value})" end |
- (self) uri(value = nil)
value
.
When the uri has query parameters, they are set in the #query_params multimap, overwritting any parameters previously set.
94 95 96 97 98 99 100 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request.rb', line 94 def uri(value=nil) if value.class == String && !block_given? @j_del.java_method(:uri, [Java::java.lang.String.java_class]).call(value) return self end raise ArgumentError, "Invalid arguments when calling uri(#{value})" end |