Class: Sinatra::Response

### Home Classes Methods

### In Files

- lib/sinatra/base.rb

### Parent

Rack::Response

### Methods

- ::new
- #body=
- #each
- #finish

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Sinatra
- Sinatra::Application
- Sinatra::CommonLogger
- Sinatra::ExtendedRack
- Sinatra::Helpers
- Sinatra::Helpers::Stream
- Sinatra::Helpers::Stream::Application
- Sinatra::Helpers::Stream::Base
- Sinatra::Helpers::Stream::Templates
- Sinatra::Helpers::Stream::Templates::ContentTyped
- Sinatra::Helpers::Stream::Wrapper
- Sinatra::Request
- Sinatra::Request::AcceptEntry
- Sinatra::Response
- Sinatra::ShowExceptions
- Rack
- Rack::Builder

No matching classes.

# Sinatra::Response

The response object. See Rack::Response and Rack::Response::Helpers for more info: rack.rubyforge.org/doc/classes/Rack/Response.html rack.rubyforge.org/doc/classes/Rack/Response/Helpers.html

### Constants

DROP_BODY_RESPONSES

### Public Class Methods

new(*) click to toggle source

    # File lib/sinatra/base.rb, line 122
    def initialize(*)
      super
      headers['Content-Type'] ||= 'text/html'
    end

### Public Instance Methods

body=(value) click to toggle source

    # File lib/sinatra/base.rb, line 127
    def body=(value)
      value = value.body while Rack::Response === value
      @body = String === value ? [value.to_str] : value
    end

each() click to toggle source

    # File lib/sinatra/base.rb, line 132
    def each
      block_given? ? super : enum_for(:each)
    end

finish() click to toggle source

    # File lib/sinatra/base.rb, line 136
    def finish
      result = body

      if drop_content_info?
        headers.delete "Content-Length"
        headers.delete "Content-Type"
      end

      if drop_body?
        close
        result = []
      end

      if calculate_content_length?
        # if some other code has already set Content-Length, don't muck with it
        # currently, this would be the static file-handler
        headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
      end

      [status.to_i, headers, result]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.