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
- #write(data) ⇒ 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
272 273 274 275 276 277 |
# File 'lib/webrick/cgi.rb', line 272 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
301 302 303 304 305 306 307 308 309 310 |
# File 'lib/webrick/cgi.rb', line 301 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
279 280 281 282 283 284 |
# File 'lib/webrick/cgi.rb', line 279 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
286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/webrick/cgi.rb', line 286 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 |
#write(data) ⇒ Object
268 269 270 |
# File 'lib/webrick/cgi.rb', line 268 def write(data) @out_port.write(data) end |