Class: Vertx::HttpClientResponse

Inherits:
Object
  • Object
show all
Includes:
ReadStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb

Overview

Represents a client-side HTTP response.

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)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 30

def @@j_api_type.accept?(obj)
  obj.class == HttpClientResponse
end

+ (Object) j_api_type


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 self.j_api_type
  @@j_api_type
end

+ (Object) j_class


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_class
  Java::IoVertxCoreHttp::HttpClientResponse.java_class
end

+ (Object) unwrap(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.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(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.wrap(obj)
  HttpClientResponse.new(obj)
end

Instance Method Details

- (self) body_handler { ... }

Convenience method for receiving the entire request body in one piece.

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.

Yields:

  • This handler will be called after all the body has been received

Returns:

  • (self)

Raises:

  • (ArgumentError)

172
173
174
175
176
177
178
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 172

def body_handler
  if block_given?
    @j_del.java_method(:bodyHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling body_handler()"
end

- (Array<String>) cookies

Returns the Set-Cookie headers (including trailers)

Returns:

  • (Array<String>)
    the Set-Cookie headers (including trailers)

Raises:

  • (ArgumentError)

157
158
159
160
161
162
163
164
165
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 157

def cookies
  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 { ... }

Set an custom frame handler. The handler will get notified when the http stream receives an custom HTTP/2 frame. HTTP/2 permits extension of the protocol.

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

183
184
185
186
187
188
189
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 183

def custom_frame_handler
  if block_given?
    @j_del.java_method(:customFrameHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::HttpFrame)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling custom_frame_handler()"
end

- (self) end_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

90
91
92
93
94
95
96
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 90

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 { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

64
65
66
67
68
69
70
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 64

def exception_handler
  if block_given?
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) fetch(amount = nil)

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

47
48
49
50
51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 47

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)

Return the first header value with the specified name

Parameters:

  • headerName (String) (defaults to: nil)
    the header name

Returns:

  • (String)
    the header value

Raises:

  • (ArgumentError)

131
132
133
134
135
136
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 131

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)

Return the first trailer value with the specified name

Parameters:

  • trailerName (String) (defaults to: nil)
    the trailer name

Returns:

  • (String)
    the trailer value

Raises:

  • (ArgumentError)

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 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 { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 73

def handler
  if block_given?
    @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler()"
end

- (::Vertx::MultiMap) headers

Returns the headers

Returns:

Raises:

  • (ArgumentError)

119
120
121
122
123
124
125
126
127
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 119

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

Get a net socket for the underlying connection of this request.

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.

Returns:

Raises:

  • (ArgumentError)

199
200
201
202
203
204
205
206
207
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 199

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

Returns:

  • (self)

Raises:

  • (ArgumentError)

81
82
83
84
85
86
87
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 81

def pause
  if !block_given?
    @j_del.java_method(:pause, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling pause()"
end

- (::Vertx::HttpClientRequest) request

Returns the corresponding request

Returns:

Raises:

  • (ArgumentError)

209
210
211
212
213
214
215
216
217
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 209

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

Returns:

  • (self)

Raises:

  • (ArgumentError)

55
56
57
58
59
60
61
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 55

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

Returns the status code of the response

Returns:

  • (Fixnum)
    the status code of the response

Raises:

  • (ArgumentError)

105
106
107
108
109
110
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 105

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

Returns the status message of the response

Returns:

  • (String)
    the status message of the response

Raises:

  • (ArgumentError)

112
113
114
115
116
117
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 112

def status_message
  if !block_given?
    return @j_del.java_method(:statusMessage, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling status_message()"
end

- (self) stream_priority_handler { ... }

Set an handler for stream priority changes.

This is not implemented for HTTP/1.x.

Yields:

  • the handler to be called when the stream priority changes

Returns:

  • (self)

Raises:

  • (ArgumentError)

223
224
225
226
227
228
229
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 223

def stream_priority_handler
  if block_given?
    @j_del.java_method(:streamPriorityHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling stream_priority_handler()"
end

- (::Vertx::MultiMap) trailers

Returns the trailers

Returns:

Raises:

  • (ArgumentError)

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 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

Returns the version of the response

Returns:

  • (:HTTP_1_0, :HTTP_1_1, :HTTP_2)
    the version of the response

Raises:

  • (ArgumentError)

98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_client_response.rb', line 98

def version
  if !block_given?
    return @j_del.java_method(:version, []).call().name.intern
  end
  raise ArgumentError, "Invalid arguments when calling version()"
end