Class: VertxWebClient::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb

Overview

An HTTP response.

The usual HTTP response attributes are available:

The body of the response is returned by #body decoded as the format specified by the VertxWebCommon::BodyCodec that built the response.

Keep in mind that using this HttpResponse impose to fully buffer the response body and should be used for payload that can fit in memory.

Instance Method Summary (collapse)

Instance Method Details

- (Object) body

Returns the response body in the format it was decoded.

Returns:

  • (Object)
    the response body in the format it was decoded.


100
101
102
103
104
105
106
107
108
109
110
111
112
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 100

def body
  if !block_given?
    if @cached_body != nil
      return @cached_body
    end
    return @cached_body = @j_arg_T.wrap(@j_del.java_method(:body, []).call())
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body()"
  end
end

- (::Vertx::Buffer) bodyAsBuffer

Returns the response body decoded as a , or null if a codec other than was used

Returns:

  • (::Vertx::Buffer)
    the response body decoded as a , or null if a codec other than was used


231
232
233
234
235
236
237
238
239
240
241
242
243
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 231

def body_as_buffer
  if !block_given?
    if @cached_body_as_buffer != nil
      return @cached_body_as_buffer
    end
    return @cached_body_as_buffer = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:bodyAsBuffer, []).call(),::Vertx::Buffer)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body_as_buffer()"
  end
end

- (Object) bodyAsJson(type)

Returns the response body decoded as the specified type with the Jackson mapper, or null if a codec other than was used

Parameters:

  • type (Nil)

Returns:

  • (Object)
    the response body decoded as the specified type with the Jackson mapper, or null if a codec other than was used


175
176
177
178
179
180
181
182
183
184
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 175

def body_as_json(*args)
  if args[0].class == Class && !block_given?
    return ::Vertx::Util::Utils.v_type_of(args[0]).wrap(@j_del.java_method(:bodyAsJson, [Java::JavaLang::Class.java_class]).call(::Vertx::Util::Utils.j_class_of(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body_as_json(#{args[0]})"
  end
end

- (Array<String,Object>) bodyAsJsonArray

Returns the response body decoded as a , or null if a codec other than was used

Returns:

  • (Array<String,Object>)
    the response body decoded as a , or null if a codec other than was used


51
52
53
54
55
56
57
58
59
60
61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 51

def body_as_json_array
  if !block_given?
    if @cached_body_as_json_array != nil
      return @cached_body_as_json_array
    end
    return @cached_body_as_json_array = @j_del.java_method(:bodyAsJsonArray, []).call() != nil ? JSON.parse(@j_del.java_method(:bodyAsJsonArray, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body_as_json_array()"
  end
end

- (Hash{String => Object}) bodyAsJsonObject

Returns the response body decoded as , or null if a codec other than was used

Returns:

  • (Hash{String => Object})
    the response body decoded as , or null if a codec other than was used


85
86
87
88
89
90
91
92
93
94
95
96
97
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 85

def body_as_json_object
  if !block_given?
    if @cached_body_as_json_object != nil
      return @cached_body_as_json_object
    end
    return @cached_body_as_json_object = @j_del.java_method(:bodyAsJsonObject, []).call() != nil ? JSON.parse(@j_del.java_method(:bodyAsJsonObject, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body_as_json_object()"
  end
end

- (String) bodyAsString - (String) bodyAsString(encoding)

Returns the response body decoded as a String given a specific encoding, or null if a codec other than was used

Overloads:

  • - (String) bodyAsString(encoding)

    Parameters:

    • encoding (String)

Returns:

  • (String)
    the response body decoded as a String given a specific encoding, or null if a codec other than was used


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 68

def body_as_string(*args)
  if !block_given? && args[0] == nil
    if @cached_body_as_string != nil
      return @cached_body_as_string
    end
    return @cached_body_as_string = @j_del.java_method(:bodyAsString, []).call()
  elsif args[0].class == String && !block_given?
    return @j_del.java_method(:bodyAsString, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body_as_string(#{args[0]})"
  end
end

- (Array<String>) cookies

Returns the Set-Cookie headers (including trailers)

Returns:

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


144
145
146
147
148
149
150
151
152
153
154
155
156
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 144

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
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling cookies()"
  end
end

- (Array<String>) followedRedirects

Returns the list of all followed redirects, including the final location.

Returns:

  • (Array<String>)
    the list of all followed redirects, including the final location.


216
217
218
219
220
221
222
223
224
225
226
227
228
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 216

def followed_redirects
  if !block_given?
    if @cached_followed_redirects != nil
      return @cached_followed_redirects
    end
    return @cached_followed_redirects = @j_del.java_method(:followedRedirects, []).call().to_a.map { |elt| elt }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling followed_redirects()"
  end
end

- (String) getHeader(headerName)

Return the first header value with the specified name

Parameters:

  • headerName (String)
    the header name

Returns:

  • (String)
    the header value


204
205
206
207
208
209
210
211
212
213
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 204

def get_header(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:getHeader, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_header(#{args[0]})"
  end
end

- (String) getTrailer(trailerName)

Return the first trailer value with the specified name

Parameters:

  • trailerName (String)
    the trailer name

Returns:

  • (String)
    the trailer value


117
118
119
120
121
122
123
124
125
126
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 117

def get_trailer(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:getTrailer, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_trailer(#{args[0]})"
  end
end

- (::Vertx::MultiMap) headers

Returns the headers

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 36

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
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling headers()"
  end
end

- (Fixnum) statusCode

Returns the status code of the response

Returns:

  • (Fixnum)
    the status code of the response


246
247
248
249
250
251
252
253
254
255
256
257
258
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 246

def status_code
  if !block_given?
    if @cached_status_code != nil
      return @cached_status_code
    end
    return @cached_status_code = @j_del.java_method(:statusCode, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling status_code()"
  end
end

- (String) statusMessage

Returns the status message of the response

Returns:

  • (String)
    the status message of the response


159
160
161
162
163
164
165
166
167
168
169
170
171
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 159

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

- (::Vertx::MultiMap) trailers

Returns the trailers

Returns:



187
188
189
190
191
192
193
194
195
196
197
198
199
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 187

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
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling trailers()"
  end
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


129
130
131
132
133
134
135
136
137
138
139
140
141
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 129

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