Class: Mongrel::HeaderOut

### Home Classes Methods

### In Files

- lib/mongrel/header_out.rb

### Parent

Object

### Methods

- ::new
- #[]=

### Files

- CHANGELOG
- COPYING
- LICENSE
- README
- Makefile

### Class/Module Index

Quicksearch

- Mongrel
- Mongrel::CGIWrapper
- Mongrel::Camping
- Mongrel::Camping::CampingHandler
- Mongrel::Command
- Mongrel::Command::Base
- Mongrel::Command::Registry
- Mongrel::Configurator
- Mongrel::Const
- Mongrel::DeflateFilter
- Mongrel::DirHandler
- Mongrel::Error404Handler
- Mongrel::Gems
- Mongrel::HeaderOut
- Mongrel::HttpHandler
- Mongrel::HttpHandlerPlugin
- Mongrel::HttpParams
- Mongrel::HttpParser
- Mongrel::HttpParserError
- Mongrel::HttpRequest
- Mongrel::HttpResponse
- Mongrel::HttpServer
- Mongrel::Rails
- Mongrel::Rails::RailsConfigurator
- Mongrel::Rails::RailsHandler
- Mongrel::RedirectHandler
- Mongrel::StatisticsFilter
- Mongrel::Stats
- Mongrel::StatusHandler
- Mongrel::StopServer
- Mongrel::TimeoutError
- Mongrel::URIClassifier
- Mongrel::URIClassifier::RegistrationError
- Mongrel::URIClassifier::UsageError
- RequestLog
- RequestLog::Access
- RequestLog::Files
- RequestLog::Objects
- RequestLog::Params
- RequestLog::Threads
- IO
- Kernel
- MongrelDbg
- TCPServer

No matching classes.

# Mongrel::HeaderOut

This class implements a simple way of constructing the HTTP headers dynamically via a Hash syntax. Think of it as a write-only Hash. Refer to HttpResponse for information on how this is used.

One consequence of this write-only nature is that you can write multiple headers by just doing them twice (which is sometimes needed in HTTP), but that the normal semantics for Hash (where doing an insert replaces) is not there.

### Attributes

allowed_duplicates[RW]
out[R]

### Public Class Methods

new(out) click to toggle source

    # File lib/mongrel/header_out.rb, line 13
    def initialize(out)
      @sent = {}
      @allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
        "Warning" => true, "WWW-Authenticate" => true}
      @out = out
    end

### Public Instance Methods

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

Simply writes "#{key}: #{value}" to an output buffer.

    # File lib/mongrel/header_out.rb, line 21
    def[]=(key,value)
      if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
        @sent[key] = true
        @out.write(Const::HEADER_FORMAT % [key, value])
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.