Class: VertxWebClient::HttpRequestBuilder
- Inherits:
-
Object
- Object
- VertxWebClient::HttpRequestBuilder
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb
Overview
Instances are created by an instance, via one of the methods createXXX
corresponding to the
specific HTTP methods.
The request builder shall be configured prior making a request, the builder is immutable and when a configuration method is called, a new builder is returned allowing to expose the builder and apply further customization.
After the request builder has been configured, the methods
can be called.
The #bufferBody
configures the builder to buffer the entire HTTP response body and returns a
PayloadCodec for configuring the response body.
The send
methods perform the actual request, they can be used multiple times to perform HTTP requests.
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)
-
- (::VertxWebClient::HttpRequestBuilder) host(value = nil)
Configure the builder to use a new host value.
-
- (::VertxWebClient::HttpRequestBuilder) method(value = nil)
Configure the builder to use a new method value.
-
- (::VertxWebClient::HttpRequestBuilder) port(value = nil)
Configure the builder to use a new port value.
-
- (::VertxWebClient::HttpRequestBuilder) put_header(name = nil, value = nil)
Configure the builder to add a new HTTP header.
-
- (::VertxWebClient::HttpRequestBuilder) request_uri(value = nil)
Configure the builder to use a new request URI value.
-
- (void) send(codec = nil) { ... }
Send a request, the handler will receive the response as an .
-
- (void) send_buffer(body = nil) { ... }
Like #send but with an HTTP request body buffer.
-
- (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_stream(body = nil) { ... }
Like #send but with an HTTP request body stream.
-
- (::VertxWebClient::HttpRequestBuilder) 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.
Class Method Details
+ (Boolean) accept?(obj)
40 41 42 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 40 def @@j_api_type.accept?(obj) obj.class == HttpRequestBuilder end |
+ (Object) j_api_type
49 50 51 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 49 def self.j_api_type @@j_api_type end |
+ (Object) j_class
52 53 54 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 52 def self.j_class Java::IoVertxWebclient::HttpRequestBuilder.java_class end |
+ (Object) unwrap(obj)
46 47 48 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 46 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
43 44 45 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 43 def @@j_api_type.wrap(obj) HttpRequestBuilder.new(obj) end |
Instance Method Details
- (::VertxWebClient::HttpRequestBuilder) host(value = nil)
value
.
76 77 78 79 80 81 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 76 def host(value=nil) if value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:host, [Java::java.lang.String.java_class]).call(value),::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling host(#{value})" end |
- (::VertxWebClient::HttpRequestBuilder) method(value = nil)
value
.
58 59 60 61 62 63 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 58 def method(value=nil) if value.class == Symbol && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:method, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(value)),::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling method(#{value})" end |
- (::VertxWebClient::HttpRequestBuilder) port(value = nil)
value
.
67 68 69 70 71 72 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 67 def port(value=nil) if value.class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:port, [Java::int.java_class]).call(value),::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling port(#{value})" end |
- (::VertxWebClient::HttpRequestBuilder) put_header(name = nil, value = nil)
95 96 97 98 99 100 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 95 def put_header(name=nil,value=nil) if name.class == String && value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:putHeader, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value),::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling put_header(#{name},#{value})" end |
- (::VertxWebClient::HttpRequestBuilder) request_uri(value = nil)
value
.
85 86 87 88 89 90 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 85 def request_uri(value=nil) if value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:uri, [Java::java.lang.String.java_class]).call(value), ::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling request_uri(#{value})" end |
- (void) send(codec = nil) { ... }
This method returns an undefined value.
Send a request, thehandler
will receive the response as an .
148 149 150 151 152 153 154 155 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 148 def send(codec=nil) if block_given? && codec == nil 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,::Vertx::Buffer.j_api_type) : nil) })) elsif codec.class.method_defined?(:j_del) && block_given? return @j_del.java_method(:send, [Java::IoVertxWebclient::PayloadCodec.java_class,Java::IoVertxCore::Handler.java_class]).call(codec.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(#{codec})" end |
- (void) send_buffer(body = nil) { ... }
127 128 129 130 131 132 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 127 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, ::Vertx::Buffer.j_api_type) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_buffer(#{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
.
138 139 140 141 142 143 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 138 def send_json(body=nil) if ::Vertx::Util::unknown_type.accept?(body) && block_given? return @j_del.java_method(:sendJsonPOJO, [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, ::Vertx::Buffer.j_api_type) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_json(#{body})" end |
- (void) send_stream(body = nil) { ... }
117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 117 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,::Vertx::Buffer.j_api_type) : nil) })) end raise ArgumentError, "Invalid arguments when calling send_stream(#{body})" end |
- (::VertxWebClient::HttpRequestBuilder) timeout(value = nil)
Setting zero or a negative value
disables the timeout.
107 108 109 110 111 112 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_builder.rb', line 107 def timeout(value=nil) if value.class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:timeout, [Java::long.java_class]).call(value),::VertxWebClient::HttpRequestBuilder) end raise ArgumentError, "Invalid arguments when calling timeout(#{value})" end |