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.

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 112

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
  raise ArgumentError, "Invalid arguments when calling body()"
end

- (::Vertx::Buffer) body_as_buffer

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

Raises:

  • (ArgumentError)


122
123
124
125
126
127
128
129
130
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 122

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
  raise ArgumentError, "Invalid arguments when calling body_as_buffer()"
end

- (Object) body_as_json(type = nil)

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) (defaults to: nil)

Returns:

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

Raises:

  • (ArgumentError)


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 166

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

- (Array<String,Object>) body_as_json_array

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

Raises:

  • (ArgumentError)


155
156
157
158
159
160
161
162
163
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 155

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
  raise ArgumentError, "Invalid arguments when calling body_as_json_array()"
end

- (Hash{String => Object}) body_as_json_object

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

Raises:

  • (ArgumentError)


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

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
  raise ArgumentError, "Invalid arguments when calling body_as_json_object()"
end

- (String) body_as_string(encoding = nil)

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

Parameters:

  • encoding (String) (defaults to: nil)

Returns:

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

Raises:

  • (ArgumentError)


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

def body_as_string(encoding=nil)
  if !block_given? && encoding == 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 encoding.class == String && !block_given?
    return @j_del.java_method(:bodyAsString, [Java::java.lang.String.java_class]).call(encoding)
  end
  raise ArgumentError, "Invalid arguments when calling body_as_string(#{encoding})"
end

- (Array<String>) cookies

Returns the Set-Cookie headers (including trailers)

Returns:

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

Raises:

  • (ArgumentError)


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

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

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


76
77
78
79
80
81
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 76

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)


95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 95

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

- (::Vertx::MultiMap) headers

Returns the headers

Returns:

Raises:

  • (ArgumentError)


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

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

- (Fixnum) status_code

Returns the status code of the response

Returns:

  • (Fixnum)
    the status code of the response

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 44

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


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

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
  raise ArgumentError, "Invalid arguments when calling status_message()"
end

- (::Vertx::MultiMap) trailers

Returns the trailers

Returns:

Raises:

  • (ArgumentError)


83
84
85
86
87
88
89
90
91
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 83

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)


34
35
36
37
38
39
40
41
42
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-client/http_response.rb', line 34

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
  raise ArgumentError, "Invalid arguments when calling version()"
end