Class List Method List File List

# Class: Vertx::HttpConnection

Inherits:
  Object
  - Object
  - Vertx::HttpConnection
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb

## Overview

Represents an HTTP connection.

HTTP/1.x connection provides an limited implementation, the following methods are implemented:

- #close
- #close_handler
- #exception_handler

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

- - (void) close
  Close the connection and all the currently active streams.
- - (self) close_handler { ... }
  Set a close handler.
- - (self) exception_handler { ... }
  Set an handler called when a connection error happens.
- - (Fixnum) get_window_size
  The current connection window size or -1 for HTTP/1.x.
- - (self) go_away(errorCode = nil, lastStreamId = nil, debugData = nil)
  Send a go away frame to the remote endpoint of the connection.
- - (self) go_away_handler { ... }
  Set an handler called when a frame is received.
- - (String) indicated_server_name
  Returns the SNI server name presented during the SSL handshake by the client.
- - (::Vertx::SocketAddress) local_address
  The remote address for this connection.
- - (self) ping(data = nil) { ... }
  Send a frame to the remote endpoint.
- - (self) ping_handler { ... }
  Set an handler notified when a frame is received from the remote endpoint.
- - (::Vertx::SocketAddress) remote_address
  The remote address for this connection.
- - (Hash) remote_settings
  The current remote endpoint settings for this connection - this is not implemented for HTTP/1.x.
- - (self) remote_settings_handler { ... }
  Set an handler that is called when remote endpoint Hash are updated.
- - (self) set_window_size(windowSize = nil)
  Update the current connection wide window size to a new size.
- - (Hash) settings
  The latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x.
- - (self) shutdown(timeoutMs = nil)
  Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current streams will be closed or the timeout is fired.
- - (self) shutdown_handler { ... }
  Set an handler called when a frame has been sent or received and all connections are closed.
- - (true, false) ssl?
  True if this HttpConnection is encrypted via SSL/TLS.
- - (self) update_settings(settings = nil) { ... }
  Send to the remote endpoint an update of this endpoint settings The completionHandler will be notified when the remote endpoint has acknowledged the settings.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    26
    27
    28
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 26

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

### + (`Object`) j_api_type

    35
    36
    37
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 35

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    38
    39
    40
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 38

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

### + (`Object`) unwrap(obj)

    32
    33
    34
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 32

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

### + (`Object`) wrap(obj)

    29
    30
    31
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 29

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

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Close the connection and all the currently active streams.

An HTTP/2 connection will send a frame before.

Raises:

- (`ArgumentError`)

    142
    143
    144
    145
    146
    147
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 142

    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. The handler will get notified when the connection is closed.

Yields:

- the handler to be notified

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    131
    132
    133
    134
    135
    136
    137
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 131

    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

### - (`self`) exception_handler { ... }

Set an handler called when a connection error happens

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    220
    221
    222
    223
    224
    225
    226
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 220

    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_window_size

Returns the current connection window size or `-1` for HTTP/1.x

Returns:

- (`Fixnum`) —
  the current connection window size or `-1` for HTTP/1.x

Raises:

- (`ArgumentError`)

    42
    43
    44
    45
    46
    47
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 42

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

### - (`self`) go_away(errorCode = nil, lastStreamId = nil, debugData = nil)

Send a go away frame to the remote endpoint of the connection.

- a frame is sent to the to the remote endpoint with the `errorCode` and `debugData`
- any stream created after the stream identified by `lastStreamId` will be closed
- for an is different than `0` when all the remaining streams are closed this connection will be closed automatically

This is not implemented for HTTP/1.x.

Parameters:

- errorCode (`Fixnum`) (defaults to: `nil`) —
  the error code
- lastStreamId (`Fixnum`) (defaults to: `nil`) —
  the last stream id
- debugData (`::Vertx::Buffer`) (defaults to: `nil`) —
  additional debug data sent to the remote endpoint

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 75

    def go_away(errorCode=nil,lastStreamId=nil,debugData=nil)
      if errorCode.class == Fixnum && !block_given? && lastStreamId == nil && debugData == nil
        @j_del.java_method(:goAway, [Java::long.java_class]).call(errorCode)
        return self
      elsif errorCode.class == Fixnum && lastStreamId.class == Fixnum && !block_given? && debugData == nil
        @j_del.java_method(:goAway, [Java::long.java_class,Java::int.java_class]).call(errorCode,lastStreamId)
        return self
      elsif errorCode.class == Fixnum && lastStreamId.class == Fixnum && debugData.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:goAway, [Java::long.java_class,Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class]).call(errorCode,lastStreamId,debugData.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling go_away(#{errorCode},#{lastStreamId},#{debugData})"
    end

### - (`self`) go_away_handler { ... }

Set an handler called when a frame is received.

This is not implemented for HTTP/1.x.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    93
    94
    95
    96
    97
    98
    99
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 93

    def go_away_handler
      if block_given?
        @j_del.java_method(:goAwayHandler, [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 go_away_handler()"
    end

### - (`String`) indicated_server_name

Returns the SNI server name presented during the SSL handshake by the client.

Returns:

- (`String`) —
  the indicated server name

Raises:

- (`ArgumentError`)

    256
    257
    258
    259
    260
    261
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 256

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

### - (`::Vertx::SocketAddress`) local_address

Returns the remote address for this connection

Returns:

- (`::Vertx::SocketAddress`) —
  the remote address for this connection

Raises:

- (`ArgumentError`)

    238
    239
    240
    241
    242
    243
    244
    245
    246
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 238

    def local_address
      if !block_given?
        if @cached_local_address != nil
          return @cached_local_address
        end
        return @cached_local_address = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:localAddress, []).call(),::Vertx::SocketAddress)
      end
      raise ArgumentError, "Invalid arguments when calling local_address()"
    end

### - (`self`) ping(data = nil) { ... }

Send a frame to the remote endpoint.

This is not implemented for HTTP/1.x.

Parameters:

- data (`::Vertx::Buffer`) (defaults to: `nil`) —
  the 8 bytes data of the frame

Yields:

- an async result handler notified with pong reply or the failure

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    198
    199
    200
    201
    202
    203
    204
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 198

    def ping(data=nil)
      if data.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:ping, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Buffer) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling ping(#{data})"
    end

### - (`self`) ping_handler { ... }

Set an handler notified when a frame is received from the remote endpoint.

This is not implemented for HTTP/1.x.

Yields:

- the handler to be called when a is received

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    210
    211
    212
    213
    214
    215
    216
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 210

    def ping_handler
      if block_given?
        @j_del.java_method(:pingHandler, [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 ping_handler()"
    end

### - (`::Vertx::SocketAddress`) remote_address

Returns the remote address for this connection

Returns:

- (`::Vertx::SocketAddress`) —
  the remote address for this connection

Raises:

- (`ArgumentError`)

    228
    229
    230
    231
    232
    233
    234
    235
    236
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 228

    def remote_address
      if !block_given?
        if @cached_remote_address != nil
          return @cached_remote_address
        end
        return @cached_remote_address = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:remoteAddress, []).call(),::Vertx::SocketAddress)
      end
      raise ArgumentError, "Invalid arguments when calling remote_address()"
    end

### - (`Hash`) remote_settings

Returns the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x

Returns:

- (`Hash`) —
  the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x

Raises:

- (`ArgumentError`)

    174
    175
    176
    177
    178
    179
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 174

    def remote_settings
      if !block_given?
        return @j_del.java_method(:remoteSettings, []).call() != nil ? JSON.parse(@j_del.java_method(:remoteSettings, []).call().toJson.encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling remote_settings()"
    end

### - (`self`) remote_settings_handler { ... }

Set an handler that is called when remote endpoint Hash are updated.

This is not implemented for HTTP/1.x.

Yields:

- the handler for remote endpoint settings

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    185
    186
    187
    188
    189
    190
    191
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 185

    def remote_settings_handler
      if block_given?
        @j_del.java_method(:remoteSettingsHandler, [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 remote_settings_handler()"
    end

### - (`self`) set_window_size(windowSize = nil)

Update the current connection wide window size to a new size.

Increasing this value, gives better performance when several data streams are multiplexed

This is not implemented for HTTP/1.x.

Parameters:

- windowSize (`Fixnum`) (defaults to: `nil`) —
  the new window size

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    55
    56
    57
    58
    59
    60
    61
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 55

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

### - (`Hash`) settings

Returns the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x

Returns:

- (`Hash`) —
  the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x

Raises:

- (`ArgumentError`)

    149
    150
    151
    152
    153
    154
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 149

    def settings
      if !block_given?
        return @j_del.java_method(:settings, []).call() != nil ? JSON.parse(@j_del.java_method(:settings, []).call().toJson.encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling settings()"
    end

### - (`self`) shutdown(timeoutMs = nil)

Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current streams will be closed or the `timeout` is fired.

This is not implemented for HTTP/1.x.

Parameters:

- timeoutMs (`Fixnum`) (defaults to: `nil`) —
  the timeout in milliseconds

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 118

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

### - (`self`) shutdown_handler { ... }

Set an handler called when a frame has been sent or received and all connections are closed.

This is not implemented for HTTP/1.x.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    105
    106
    107
    108
    109
    110
    111
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 105

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

### - (`true`, `false`) ssl?

Returns true if this Vertx::HttpConnection is encrypted via SSL/TLS.

Returns:

- (`true`, `false`) —
  true if this Vertx::HttpConnection is encrypted via SSL/TLS.

Raises:

- (`ArgumentError`)

    248
    249
    250
    251
    252
    253
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 248

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

### - (`self`) update_settings(settings = nil) { ... }

Send to the remote endpoint an update of this endpoint settings

The `completionHandler` will be notified when the remote endpoint has acknowledged the settings.

This is not implemented for HTTP/1.x.

Parameters:

- settings (`Hash`) (defaults to: `nil`) —
  the new settings

Yields:

- the handler notified when the settings have been acknowledged by the remote endpoint

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/http_connection.rb', line 163

    def update_settings(settings=nil)
      if settings.class == Hash && !block_given?
        @j_del.java_method(:updateSettings, [Java::IoVertxCoreHttp::Http2Settings.java_class]).call(Java::IoVertxCoreHttp::Http2Settings.new(::Vertx::Util::Utils.to_json_object(settings)))
        return self
      elsif settings.class == Hash && block_given?
        @j_del.java_method(:updateSettings, [Java::IoVertxCoreHttp::Http2Settings.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::Http2Settings.new(::Vertx::Util::Utils.to_json_object(settings)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling update_settings(#{settings})"
    end