Class: WEBrick::CGI::Socket

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/webrick/cgi.rb

Overview

Provides HTTP socket emulation from the CGI environment

Instance Method Summary collapse

Instance Method Details

#<<(data) ⇒ Object



263
264
265
# File 'lib/webrick/cgi.rb', line 263

def <<(data)
  @out_port << data
end

#addrObject



243
244
245
# File 'lib/webrick/cgi.rb', line 243

def addr
  [nil, @server_port, @server_name, @server_addr]
end

#certObject



267
268
269
270
271
272
# File 'lib/webrick/cgi.rb', line 267

def cert
  return nil unless defined?(OpenSSL)
  if pem = @env["SSL_SERVER_CERT"]
    OpenSSL::X509::Certificate.new(pem) unless pem.empty?
  end
end

#cipherObject



296
297
298
299
300
301
302
303
304
305
# File 'lib/webrick/cgi.rb', line 296

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

#eachObject



255
256
257
# File 'lib/webrick/cgi.rb', line 255

def each
  input.each{|line| yield(line) }
end

#eof?Boolean

Returns:

  • (Boolean)


259
260
261
# File 'lib/webrick/cgi.rb', line 259

def eof?
  input.eof?
end

#gets(eol = LF, size = nil) ⇒ Object



247
248
249
# File 'lib/webrick/cgi.rb', line 247

def gets(eol=LF, size=nil)
  input.gets(eol, size)
end

#peer_certObject



274
275
276
277
278
279
# File 'lib/webrick/cgi.rb', line 274

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_chainObject



281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/webrick/cgi.rb', line 281

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

#peeraddrObject



239
240
241
# File 'lib/webrick/cgi.rb', line 239

def peeraddr
  [nil, @remote_port, @remote_host, @remote_addr]
end

#read(size = nil) ⇒ Object



251
252
253
# File 'lib/webrick/cgi.rb', line 251

def read(size=nil)
  input.read(size)
end