Class: Vertx::HttpServerResponse

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

Overview

Represents a server-side HTTP response.

An instance of this is created and associated to every instance of HttpServerRequest that.

It allows the developer to control the HTTP response that is sent back to the client for a particular HTTP request.

It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response.

It also allows files to be streamed by the kernel directly from disk to the outgoing HTTP connection, bypassing user space altogether (where supported by the underlying operating system). This is a very efficient way of serving files from the server since buffers do not have to be read one by one from the file and written to the outgoing socket.

It implements WriteStream 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)

39
40
41
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 39

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

+ (Object) j_api_type


48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 48

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 51

def self.j_class
  Java::IoVertxCoreHttp::HttpServerResponse.java_class
end

+ (Object) unwrap(obj)


45
46
47
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 45

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 42

def @@j_api_type.wrap(obj)
  HttpServerResponse.new(obj)
end

Instance Method Details

- (self) body_end_handler { ... }

Provides a handler that will be called after the last part of the body is written to the wire. The handler is called asynchronously of when the response has been received by the client. This provides a hook allowing you to do more operations once the request has been sent over the wire such as resource cleanup.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

388
389
390
391
392
393
394
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 388

def body_end_handler
  if block_given?
    @j_del.java_method(:bodyEndHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling body_end_handler()"
end

- (Fixnum) bytes_written

Returns the total number of bytes written for the body of the response.

Returns:

  • (Fixnum)
    the total number of bytes written for the body of the response.

Raises:

  • (ArgumentError)

396
397
398
399
400
401
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 396

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

- (true, false) chunked?

Returns is the response chunked?

Returns:

  • (true, false)
    is the response chunked?

Raises:

  • (ArgumentError)

228
229
230
231
232
233
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 228

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

- (void) close

This method returns an undefined value.

Close the underlying TCP connection corresponding to the request.

Raises:

  • (ArgumentError)

344
345
346
347
348
349
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 344

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

- (self) close_handler { ... }

Set a close handler for the response, this is called when the underlying connection is closed and the response was still using the connection.

For HTTP/1.x it is called when the connection is closed before end() is called, therefore it is not guaranteed to be called.

For HTTP/2 it is called when the related stream is closed, and therefore it will be always be called.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

285
286
287
288
289
290
291
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 285

def close_handler
  if block_given?
    @j_del.java_method(:closeHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling close_handler()"
end

- (true, false) closed?

Returns has the underlying TCP connection corresponding to the request already been closed?

Returns:

  • (true, false)
    has the underlying TCP connection corresponding to the request already been closed?

Raises:

  • (ArgumentError)

358
359
360
361
362
363
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 358

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

- (self) drain_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

165
166
167
168
169
170
171
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 165

def drain_handler
  if block_given?
    @j_del.java_method(:drainHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling drain_handler()"
end

- (void) end - (void) end(handler) { ... } - (void) end(chunk) - (void) end(chunk) - (void) end(chunk, handler) { ... } - (void) end(chunk, enc) - (void) end(chunk, handler) { ... } - (void) end(chunk, enc, handler) { ... }

This method returns an undefined value.

Same as #end but with an handler called when the operation completes

Overloads:

  • - (void) end(handler) { ... }

    Yields:

  • - (void) end(chunk)

    Parameters:

    • chunk (String)
      the string to write before ending the response
  • - (void) end(chunk)

    Parameters:

    • chunk (::Vertx::Buffer)
      the buffer to write before ending the response
  • - (void) end(chunk, handler) { ... }

    Parameters:

    • chunk (String)

    Yields:

  • - (void) end(chunk, enc)

    Parameters:

    • chunk (String)
      the string to write before ending the response
    • enc (String)
      the encoding to use
  • - (void) end(chunk, handler) { ... }

    Parameters:

    Yields:

  • - (void) end(chunk, enc, handler) { ... }

    Parameters:

    • chunk (String)
    • enc (String)

    Yields:

Raises:

  • (ArgumentError)

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 76

def end(param_1=nil,param_2=nil)
  if !block_given? && param_1 == nil && param_2 == nil
    return @j_del.java_method(:end, []).call()
  elsif block_given? && param_1 == nil && param_2 == nil
    return @j_del.java_method(:end, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  elsif param_1.class == String && !block_given? && param_2 == nil
    return @j_del.java_method(:end, [Java::java.lang.String.java_class]).call(param_1)
  elsif param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
    return @j_del.java_method(:end, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(param_1.j_del)
  elsif param_1.class == String && block_given? && param_2 == nil
    return @j_del.java_method(:end, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  elsif param_1.class == String && param_2.class == String && !block_given?
    return @j_del.java_method(:end, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(param_1,param_2)
  elsif param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil
    return @j_del.java_method(:end, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  elsif param_1.class == String && param_2.class == String && block_given?
    return @j_del.java_method(:end, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling end(#{param_1},#{param_2})"
end

- (self) end_handler { ... }

Set an end handler for the response. This will be called when the response is disposed to allow consistent cleanup of the response.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

296
297
298
299
300
301
302
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 296

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

- (true, false) ended?

Returns has the response already ended?

Returns:

  • (true, false)
    has the response already ended?

Raises:

  • (ArgumentError)

351
352
353
354
355
356
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 351

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

- (self) exception_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

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

- (Fixnum) get_status_code

Returns the HTTP status code of the response. The default is 200 representing OK.

Returns:

  • (Fixnum)
    the HTTP status code of the response. The default is 200 representing OK.

Raises:

  • (ArgumentError)

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

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

- (String) get_status_message

Returns the HTTP status message of the response. If this is not specified a default value will be used depending on what #set_status_code has been set to.

Returns:

  • (String)
    the HTTP status message of the response. If this is not specified a default value will be used depending on what #set_status_code has been set to.

Raises:

  • (ArgumentError)

191
192
193
194
195
196
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 191

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

- (true, false) head_written?

Returns have the headers for the response already been written?

Returns:

  • (true, false)
    have the headers for the response already been written?

Raises:

  • (ArgumentError)

365
366
367
368
369
370
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 365

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

- (::Vertx::MultiMap) headers

Returns The HTTP headers

Returns:

Raises:

  • (ArgumentError)

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/http_server_response.rb', line 235

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

Provide a handler that will be called just before the headers are written to the wire.

This provides a hook allowing you to add any more headers or do any more operations before this occurs.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

375
376
377
378
379
380
381
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 375

def headers_end_handler
  if block_given?
    @j_del.java_method(:headersEndHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling headers_end_handler()"
end

- (self) push(method, path, handler) { ... } - (self) push(method, host, path, handler) { ... } - (self) push(method, path, headers, handler) { ... } - (self) push(method, host, path, headers, handler) { ... }

Push a response to the client.

The handler will be notified with a success when the push can be sent and with a failure when the client has disabled push or reset the push before it has been sent.

The handler may be queued if the client has reduced the maximum number of streams the server can push concurrently.

Push can be sent only for peer initiated streams and if the response is not ended.

Overloads:

  • - (self) push(method, path, handler) { ... }

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
    • path (String)

    Yields:

  • - (self) push(method, host, path, handler) { ... }

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
    • host (String)
    • path (String)

    Yields:

  • - (self) push(method, path, headers, handler) { ... }

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
    • path (String)
    • headers (::Vertx::MultiMap)

    Yields:

  • - (self) push(method, host, path, headers, handler) { ... }

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
      the method of the promised request
    • host (String)
      the host of the promised request
    • path (String)
      the path of the promised request
    • headers (::Vertx::MultiMap)
      the headers of the promised request

    Yields:

    • the handler notified when the response can be written

Returns:

  • (self)

Raises:

  • (ArgumentError)

439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 439

def push(param_1=nil,param_2=nil,param_3=nil,param_4=nil)
  if param_1.class == Symbol && param_2.class == String && block_given? && param_3 == nil && param_4 == nil
    @j_del.java_method(:push, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1.to_s),param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::HttpServerResponse) : nil) }))
    return self
  elsif param_1.class == Symbol && param_2.class == String && param_3.class == String && block_given? && param_4 == nil
    @j_del.java_method(:push, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1.to_s),param_2,param_3,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::HttpServerResponse) : nil) }))
    return self
  elsif param_1.class == Symbol && param_2.class == String && param_3.class.method_defined?(:j_del) && block_given? && param_4 == nil
    @j_del.java_method(:push, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::MultiMap.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1.to_s),param_2,param_3.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::HttpServerResponse) : nil) }))
    return self
  elsif param_1.class == Symbol && param_2.class == String && param_3.class == String && param_4.class.method_defined?(:j_del) && block_given?
    @j_del.java_method(:push, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::MultiMap.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1.to_s),param_2,param_3,param_4.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::HttpServerResponse) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling push(#{param_1},#{param_2},#{param_3},#{param_4})"
end

- (self) put_header(name = nil, value = nil)

Put an HTTP header

Parameters:

  • name (String) (defaults to: nil)
    the header name
  • value (String) (defaults to: nil)
    the header value.

Returns:

  • (self)

Raises:

  • (ArgumentError)

248
249
250
251
252
253
254
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 248

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

- (self) put_trailer(name = nil, value = nil)

Put an HTTP trailer

Parameters:

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

Returns:

  • (self)

Raises:

  • (ArgumentError)

269
270
271
272
273
274
275
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 269

def put_trailer(name=nil,value=nil)
  if name.class == String && value.class == String && !block_given?
    @j_del.java_method(:putTrailer, [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_trailer(#{name},#{value})"
end

- (void) reset(code = nil)

This method returns an undefined value.

Reset this HTTP/2 stream with the error code.

Parameters:

  • code (Fixnum) (defaults to: nil)
    the error code

Raises:

  • (ArgumentError)

458
459
460
461
462
463
464
465
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 458

def reset(code=nil)
  if !block_given? && code == nil
    return @j_del.java_method(:reset, []).call()
  elsif code.class == Fixnum && !block_given?
    return @j_del.java_method(:reset, [Java::long.java_class]).call(code)
  end
  raise ArgumentError, "Invalid arguments when calling reset(#{code})"
end

- (self) send_file(filename = nil, offset = nil, length = nil) { ... }

Like #send_file but providing a handler which will be notified once the file has been completely written to the wire.

Parameters:

  • filename (String) (defaults to: nil)
    path to the file to serve
  • offset (Fixnum) (defaults to: nil)
    the offset to serve from
  • length (Fixnum) (defaults to: nil)
    the length to serve to

Yields:

  • handler that will be called on completion

Returns:

  • (self)

Raises:

  • (ArgumentError)

320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 320

def send_file(filename=nil,offset=nil,length=nil)
  if filename.class == String && !block_given? && offset == nil && length == nil
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class]).call(filename)
    return self
  elsif filename.class == String && offset.class == Fixnum && !block_given? && length == nil
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class,Java::long.java_class]).call(filename,offset)
    return self
  elsif filename.class == String && block_given? && offset == nil && length == nil
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(filename,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  elsif filename.class == String && offset.class == Fixnum && length.class == Fixnum && !block_given?
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class,Java::long.java_class,Java::long.java_class]).call(filename,offset,length)
    return self
  elsif filename.class == String && offset.class == Fixnum && block_given? && length == nil
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(filename,offset,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  elsif filename.class == String && offset.class == Fixnum && length.class == Fixnum && block_given?
    @j_del.java_method(:sendFile, [Java::java.lang.String.java_class,Java::long.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(filename,offset,length,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling send_file(#{filename},#{offset},#{length})"
end

- (self) set_chunked(chunked = nil)

If chunked is true, this response will use HTTP chunked encoding, and each call to write to the body will correspond to a new HTTP chunk sent on the wire.

If chunked encoding is used the HTTP header Transfer-Encoding with a value of Chunked will be automatically inserted in the response.

If chunked is false, this response will not use HTTP chunked encoding, and therefore the total size of any data that is written in the respone body must be set in the Content-Length header before any data is written out.

An HTTP chunked response is typically used when you do not know the total size of the request body up front.

Parameters:

  • chunked (true, false) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

220
221
222
223
224
225
226
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 220

def set_chunked(chunked=nil)
  if (chunked.class == TrueClass || chunked.class == FalseClass) && !block_given?
    @j_del.java_method(:setChunked, [Java::boolean.java_class]).call(chunked)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_chunked(#{chunked})"
end

- (self) set_status_code(statusCode = nil)

Set the status code. If the status message hasn't been explicitly set, a default status message corresponding to the code will be looked-up and used.

Parameters:

  • statusCode (Fixnum) (defaults to: nil)

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_server_response.rb', line 183

def set_status_code(statusCode=nil)
  if statusCode.class == Fixnum && !block_given?
    @j_del.java_method(:setStatusCode, [Java::int.java_class]).call(statusCode)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_status_code(#{statusCode})"
end

- (self) set_status_message(statusMessage = nil)

Set the status message

Parameters:

  • statusMessage (String) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def set_status_message(statusMessage=nil)
  if statusMessage.class == String && !block_given?
    @j_del.java_method(:setStatusMessage, [Java::java.lang.String.java_class]).call(statusMessage)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_status_message(#{statusMessage})"
end

- (self) set_stream_priority(streamPriority = nil)

Sets the priority of the associated stream

This is not implemented for HTTP/1.x.

Parameters:

  • streamPriority (Hash) (defaults to: nil)
    the priority for this request's stream

Returns:

  • (self)

Raises:

  • (ArgumentError)

491
492
493
494
495
496
497
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 491

def set_stream_priority(streamPriority=nil)
  if streamPriority.class == Hash && !block_given?
    @j_del.java_method(:setStreamPriority, [Java::IoVertxCoreHttp::StreamPriority.java_class]).call(Java::IoVertxCoreHttp::StreamPriority.new(::Vertx::Util::Utils.to_json_object(streamPriority)))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_stream_priority(#{streamPriority})"
end

- (self) set_write_queue_max_size(maxSize = nil)

Parameters:

  • maxSize (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def set_write_queue_max_size(maxSize=nil)
  if maxSize.class == Fixnum && !block_given?
    @j_del.java_method(:setWriteQueueMaxSize, [Java::int.java_class]).call(maxSize)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_write_queue_max_size(#{maxSize})"
end

- (Fixnum) stream_id

Returns the id of the stream of this response, for HTTP/1.x

Returns:

  • (Fixnum)
    the id of the stream of this response, for HTTP/1.x

Raises:

  • (ArgumentError)

403
404
405
406
407
408
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 403

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

- (::Vertx::MultiMap) trailers

Returns The HTTP trailers

Returns:

Raises:

  • (ArgumentError)

256
257
258
259
260
261
262
263
264
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 256

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

- (self) write(data) - (self) write(chunk) - (self) write(data, handler) { ... } - (self) write(chunk, enc) - (self) write(chunk, handler) { ... } - (self) write(chunk, enc, handler) { ... }

Same as #write but with an handler called when the operation completes

Overloads:

  • - (self) write(data)

    Parameters:

  • - (self) write(chunk)

    Parameters:

    • chunk (String)
      the string to write
  • - (self) write(data, handler) { ... }

    Parameters:

    Yields:

  • - (self) write(chunk, enc)

    Parameters:

    • chunk (String)
      the string to write
    • enc (String)
      the encoding to use
  • - (self) write(chunk, handler) { ... }

    Parameters:

    • chunk (String)

    Yields:

  • - (self) write(chunk, enc, handler) { ... }

    Parameters:

    • chunk (String)
    • enc (String)

    Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

132
133
134
135
136
137
138
139
140
141
142
143
144
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/http_server_response.rb', line 132

def write(param_1=nil,param_2=nil)
  if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
    @j_del.java_method(:write, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(param_1.j_del)
    return self
  elsif param_1.class == String && !block_given? && param_2 == nil
    @j_del.java_method(:write, [Java::java.lang.String.java_class]).call(param_1)
    return self
  elsif param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil
    @j_del.java_method(:write, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  elsif param_1.class == String && param_2.class == String && !block_given?
    @j_del.java_method(:write, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(param_1,param_2)
    return self
  elsif param_1.class == String && block_given? && param_2 == nil
    @j_del.java_method(:write, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  elsif param_1.class == String && param_2.class == String && block_given?
    @j_del.java_method(:write, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling write(#{param_1},#{param_2})"
end

- (self) write_continue

Used to write an interim 100 Continue response to signify that the client should send the rest of the request. Must only be used if the request contains an "Expect:100-Continue" header

Returns:

  • (self)

Raises:

  • (ArgumentError)

306
307
308
309
310
311
312
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 306

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

- (self) writeCustomFrame(frame) - (self) writeCustomFrame(type, flags, payload)

Write an HTTP/2 frame to the response, allowing to extend the HTTP/2 protocol.

The frame is sent immediatly and is not subject to flow control.

Overloads:

  • - (self) writeCustomFrame(frame)

    Parameters:

  • - (self) writeCustomFrame(type, flags, payload)

    Parameters:

    • type (Fixnum)
      the 8-bit frame type
    • flags (Fixnum)
      the 8-bit frame flags
    • payload (::Vertx::Buffer)
      the frame payload

Returns:

  • (self)

Raises:

  • (ArgumentError)

476
477
478
479
480
481
482
483
484
485
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/http_server_response.rb', line 476

def write_custom_frame(param_1=nil,param_2=nil,param_3=nil)
  if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil && param_3 == nil
    @j_del.java_method(:writeCustomFrame, [Java::IoVertxCoreHttp::HttpFrame.java_class]).call(param_1.j_del)
    return self
  elsif param_1.class == Fixnum && param_2.class == Fixnum && param_3.class.method_defined?(:j_del) && !block_given?
    @j_del.java_method(:writeCustomFrame, [Java::int.java_class,Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class]).call(param_1,param_2,param_3.j_del)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling write_custom_frame(#{param_1},#{param_2},#{param_3})"
end

- (true, false) write_queue_full?

This will return true if there are more bytes in the write queue than the value set using #set_write_queue_max_size

Returns:

  • (true, false)
    true if write queue is full

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_server_response.rb', line 98

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