Class: WEBrick::CGI::Socket
- Inherits:
-
Object
- Object
- WEBrick::CGI::Socket
- Includes:
- Enumerable
- Defined in:
- lib/webrick/cgi.rb
Overview
Provides HTTP socket emulation from the CGI environment
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #addr ⇒ Object
- #cert ⇒ Object
- #cipher ⇒ Object
- #each ⇒ Object
- #eof? ⇒ Boolean
- #gets(eol = LF, size = nil) ⇒ Object
- #peer_cert ⇒ Object
- #peer_cert_chain ⇒ Object
- #peeraddr ⇒ Object
- #read(size = nil) ⇒ Object
Instance Method Details
#<<(data) ⇒ Object
264 265 266 |
# File 'lib/webrick/cgi.rb', line 264 def <<(data) @out_port << data end |
#addr ⇒ Object
244 245 246 |
# File 'lib/webrick/cgi.rb', line 244 def addr [nil, @server_port, @server_name, @server_addr] end |
#cert ⇒ Object
268 269 270 271 272 273 |
# File 'lib/webrick/cgi.rb', line 268 def cert return nil unless defined?(OpenSSL) if pem = @env["SSL_SERVER_CERT"] OpenSSL::X509::Certificate.new(pem) unless pem.empty? end end |
#cipher ⇒ Object
297 298 299 300 301 302 303 304 305 306 |
# File 'lib/webrick/cgi.rb', line 297 def cipher return nil unless defined?(OpenSSL) if cipher = @env["SSL_CIPHER"] ret = [ cipher ] ret << @env["SSL_PROTOCOL"] ret << @env["SSL_CIPHER_USEKEYSIZE"] ret << @env["SSL_CIPHER_ALGKEYSIZE"] ret end end |
#each ⇒ Object
256 257 258 |
# File 'lib/webrick/cgi.rb', line 256 def each input.each{|line| yield(line) } end |
#eof? ⇒ Boolean
260 261 262 |
# File 'lib/webrick/cgi.rb', line 260 def eof? input.eof? end |
#gets(eol = LF, size = nil) ⇒ Object
248 249 250 |
# File 'lib/webrick/cgi.rb', line 248 def gets(eol=LF, size=nil) input.gets(eol, size) end |
#peer_cert ⇒ Object
275 276 277 278 279 280 |
# File 'lib/webrick/cgi.rb', line 275 def peer_cert return nil unless defined?(OpenSSL) if pem = @env["SSL_CLIENT_CERT"] OpenSSL::X509::Certificate.new(pem) unless pem.empty? end end |
#peer_cert_chain ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/webrick/cgi.rb', line 282 def peer_cert_chain return nil unless defined?(OpenSSL) if @env["SSL_CLIENT_CERT_CHAIN_0"] keys = @env.keys certs = keys.sort.collect{|k| if /^SSL_CLIENT_CERT_CHAIN_\d+$/ =~ k if pem = @env[k] OpenSSL::X509::Certificate.new(pem) unless pem.empty? end end } certs.compact end end |
#peeraddr ⇒ Object
240 241 242 |
# File 'lib/webrick/cgi.rb', line 240 def peeraddr [nil, @remote_port, @remote_host, @remote_addr] end |
#read(size = nil) ⇒ Object
252 253 254 |
# File 'lib/webrick/cgi.rb', line 252 def read(size=nil) input.read(size) end |