Class: WEBrick::CGI::Socket

Class | WEBrick::CGI::Socket
In: | webrick/cgi.rb
Parent: | Object

### Methods

<< addr cert cipher each gets new peer_cert peer_cert_chain peeraddr read

### Included Modules

Enumerable

### Public Class methods

new(config, env, stdin, stdout)

[Source]

    # File webrick/cgi.rb, line 126
          def initialize(config, env, stdin, stdout)
            @config = config
            @env = env
            @header_part = StringIO.new
            @body_part = stdin
            @out_port = stdout
            @out_port.binmode

            @server_addr = @env["SERVER_ADDR"] || "0.0.0.0"
            @server_name = @env["SERVER_NAME"]
            @server_port = @env["SERVER_PORT"]
            @remote_addr = @env["REMOTE_ADDR"]
            @remote_host = @env["REMOTE_HOST"] || @remote_addr
            @remote_port = @env["REMOTE_PORT"] || 0

            begin
              @header_part << request_line << CRLF
              setup_header
              @header_part << CRLF
              @header_part.rewind
            rescue Exception => ex
              raise CGIError, "invalid CGI environment"
            end
          end

### Public Instance methods

<<(data)

[Source]

    # File webrick/cgi.rb, line 212
          def <<(data)
            @out_port << data
          end

addr()

[Source]

    # File webrick/cgi.rb, line 196
          def addr
            [nil, @server_port, @server_name, @server_addr]
          end

cert()

[Source]

    # File webrick/cgi.rb, line 216
          def cert
            return nil unless defined?(OpenSSL)
            if pem = @env["SSL_SERVER_CERT"]
              OpenSSL::X509::Certificate.new(pem) unless pem.empty?
            end
          end

cipher()

[Source]

    # File webrick/cgi.rb, line 245
          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() {|line| ...}

[Source]

    # File webrick/cgi.rb, line 208
          def each
            input.each{|line| yield(line) }
          end

gets(eol=LF)

[Source]

    # File webrick/cgi.rb, line 200
          def gets(eol=LF)
            input.gets(eol)
          end

peer_cert()

[Source]

    # File webrick/cgi.rb, line 223
          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()

[Source]

    # File webrick/cgi.rb, line 230
          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()

[Source]

    # File webrick/cgi.rb, line 192
          def peeraddr
            [nil, @remote_port, @remote_host, @remote_addr]
          end

read(size=nil)

[Source]

    # File webrick/cgi.rb, line 204
          def read(size=nil)
            input.read(size)
          end

[Validate]