Class: Thin::Headers

### Home Classes Methods

### In Files

- lib/thin/headers.rb

### Parent

Object

### Methods

- ::new
- #[]=
- #has_key?
- #to_s

### Class/Module Index

Quicksearch

- Thin
- Thin::Backends
- Thin::Backends::Base
- Thin::Backends::SwiftiplyClient
- Thin::Backends::TcpServer
- Thin::Backends::UnixServer
- Thin::Command
- Thin::Connection
- Thin::Controllers
- Thin::Controllers::Cluster
- Thin::Controllers::Controller
- Thin::Controllers::Service
- Thin::Daemonizable
- Thin::Daemonizable::ClassMethods
- Thin::Headers
- Thin::InvalidOption
- Thin::InvalidRequest
- Thin::Logging
- Thin::Logging::SimpleFormatter
- Thin::OptionRequired
- Thin::PidFileExist
- Thin::PidFileNotFound
- Thin::PlatformNotSupported
- Thin::Request
- Thin::Response
- Thin::RestartTimeout
- Thin::Runner
- Thin::RunnerError
- Thin::Server
- Thin::Stats
- Thin::Stats::Adapter
- Thin::SwiftiplyConnection
- Thin::UnixConnection
- Rack
- Rack::Adapter
- Rack::Adapter::Rails
- Rack::Adapter::Rails::CGIWrapper
- Rack::Adapter::Rails::CgiApp
- Rack::AdapterNotFound
- Process

No matching classes.

# Thin::Headers

Store HTTP header name-value pairs direcly to a string and allow duplicated entries on some names.

### Constants

ALLOWED_DUPLICATES
HEADER_FORMAT

### Public Class Methods

new() click to toggle source

    # File lib/thin/headers.rb, line 8
    def initialize
      @sent = {}
      @out = []
    end

### Public Instance Methods

[]=(key, value) click to toggle source

Add `key: value` pair to the headers. Ignore if already sent and no duplicates are allowed for this `key`.

    # File lib/thin/headers.rb, line 16
    def []=(key, value)
      downcase_key = key.downcase
      if !@sent.has_key?(downcase_key) || ALLOWED_DUPLICATES.include?(downcase_key)
        @sent[downcase_key] = true
        value = case value
                when Time
                  value.httpdate
                when NilClass
                  return
                else
                  value.to_s
                end
        @out << HEADER_FORMAT % [key, value]
      end
    end

has_key?(key) click to toggle source

    # File lib/thin/headers.rb, line 32
    def has_key?(key)
      @sent[key.downcase]
    end

to_s() click to toggle source

    # File lib/thin/headers.rb, line 36
    def to_s
      @out.join
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.