Module: OpenSSL::Buffering

Includes:
Enumerable
Included in:
SSL::SSLSocket
Defined in:
lib/framework/autocomplete/OpenSSL.rb,
lib/extensions/openssl/openssl/buffering.rb

Constant Summary collapse

BLOCK_SIZE =
1024*16

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#all?, #any?, #collect, #detect, #each_with_index, #find_all, #group_by, #inject, #max, #member?, #min, #sort, #sort_by, #to_a, #to_set

Instance Attribute Details

#syncObject

Returns the value of attribute sync.



383
384
# File 'lib/framework/autocomplete/OpenSSL.rb', line 383

def sync
end

Instance Method Details

#<<(s) ⇒ Object



419
420
# File 'lib/framework/autocomplete/OpenSSL.rb', line 419

def <<(s)
end

#closeObject



429
430
# File 'lib/framework/autocomplete/OpenSSL.rb', line 429

def close
end

#each(eol = $/) ⇒ Object Also known as: each_line



395
396
# File 'lib/framework/autocomplete/OpenSSL.rb', line 395

def each(eol)
end

#each_byteObject



405
406
# File 'lib/framework/autocomplete/OpenSSL.rb', line 405

def each_byte
end

#eof?Boolean Also known as: eof

Returns:

  • (Boolean)


411
412
# File 'lib/framework/autocomplete/OpenSSL.rb', line 411

def eof?
end

#flushObject



427
428
# File 'lib/framework/autocomplete/OpenSSL.rb', line 427

def flush
end

#getcObject



403
404
# File 'lib/framework/autocomplete/OpenSSL.rb', line 403

def getc
end

#gets(eol = $/, limit = nil) ⇒ Object



393
394
# File 'lib/framework/autocomplete/OpenSSL.rb', line 393

def gets(eol,limit)
end

#initialize(*args) ⇒ Object



23
24
25
26
27
# File 'lib/extensions/openssl/openssl/buffering.rb', line 23

def initialize(*args)
  @eof = false
  @rbuffer = ""
  @sync = @io.sync
end


423
424
# File 'lib/framework/autocomplete/OpenSSL.rb', line 423

def print(args)
end

#printf(s, *args) ⇒ Object



425
426
# File 'lib/framework/autocomplete/OpenSSL.rb', line 425

def printf(s,args)
end

#puts(*args) ⇒ Object



421
422
# File 'lib/framework/autocomplete/OpenSSL.rb', line 421

def puts(args)
end

#read(size = nil, buf = nil) ⇒ Object



387
388
# File 'lib/framework/autocomplete/OpenSSL.rb', line 387

def read(size,buf)
end

#read_nonblock(maxlen, buf = nil) ⇒ Object

Reads at most maxlen bytes in the non-blocking manner.

When no data can be read without blocking, It raises OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.

IO::WaitReadable means SSL needs to read internally. So read_nonblock should be called again after underlying IO is readable.

IO::WaitWritable means SSL needs to write internally. So read_nonblock should be called again after underlying IO is writable.

So OpenSSL::Buffering#read_nonblock needs two rescue clause as follows.

# emulates blocking read (readpartial).
begin
  result = ssl.read_nonblock(maxlen)
rescue IO::WaitReadable
  IO.select([io])
  retry
rescue IO::WaitWritable
  IO.select(nil, [io])
  retry
end

Note that one reason that read_nonblock write to a underlying IO is the peer requests a new TLS/SSL handshake. See openssl FAQ for more details. www.openssl.org/support/faq.html

Raises:

  • (EOFError)


135
136
# File 'lib/extensions/openssl/openssl/buffering.rb', line 135

def read_nonblock(maxlen,buf)
end

#readcharObject

Raises:

  • (EOFError)


407
408
# File 'lib/framework/autocomplete/OpenSSL.rb', line 407

def readchar
end

#readline(eol = $/) ⇒ Object

Raises:

  • (EOFError)


401
402
# File 'lib/framework/autocomplete/OpenSSL.rb', line 401

def readline(eol)
end

#readlines(eol = $/) ⇒ Object



399
400
# File 'lib/framework/autocomplete/OpenSSL.rb', line 399

def readlines(eol)
end

#readpartial(maxlen, buf = nil) ⇒ Object

Raises:

  • (EOFError)


389
390
# File 'lib/framework/autocomplete/OpenSSL.rb', line 389

def readpartial(maxlen,buf)
end

#ungetc(c) ⇒ Object



409
410
# File 'lib/framework/autocomplete/OpenSSL.rb', line 409

def ungetc(c)
end

#write(s) ⇒ Object



415
416
# File 'lib/framework/autocomplete/OpenSSL.rb', line 415

def write(s)
end

#write_nonblock(s) ⇒ Object

Writes str in the non-blocking manner.

If there are buffered data, it is flushed at first. This may block.

write_nonblock returns number of bytes written to the SSL connection.

When no data can be written without blocking, It raises OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.

IO::WaitReadable means SSL needs to read internally. So write_nonblock should be called again after underlying IO is readable.

IO::WaitWritable means SSL needs to write internally. So write_nonblock should be called again after underlying IO is writable.

So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows.

# emulates blocking write.
begin
  result = ssl.write_nonblock(str)
rescue IO::WaitReadable
  IO.select([io])
  retry
rescue IO::WaitWritable
  IO.select(nil, [io])
  retry
end

Note that one reason that write_nonblock read from a underlying IO is the peer requests a new TLS/SSL handshake. See openssl FAQ for more details. www.openssl.org/support/faq.html



290
291
# File 'lib/extensions/openssl/openssl/buffering.rb', line 290

def write_nonblock(s)
end