Sha256: 2552dfc5ce2b47a2308bc6ed572dc2fc77dc14ca90856fe686281631de6a0d2f

Contents?: true

Size: 928 Bytes

Versions: 3

Compression:

Stored size: 928 Bytes

Contents

module Scales
  module Worker
    module Response
      class << self
    
        def to_job(id, response)
          status, headers, chunked_body = response
          
          headers = headers.dup.keep_if do |key, value|
            key.match /^HTTP_/ or
            [
              'Location', 
              'Content-Type', 
              'Set-Cookie',
              'REQUEST_METHOD',
              'SCRIPT_NAME',
              'PATH_INFO',
              'QUERY_STRING',
              'SERVER_NAME',
              'SERVER_PORT'
            ].include?(key)
          end
          headers['scales.id'] = id
          
          body = ""
          chunked_body.each{ |chunk| body << chunk }
          
          [status, headers, body]
        end
        
        def to_string(response)
          body = ""
          response.last.each{ |chunk| body << chunk }
          body
        end
    
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-worker-0.0.4 lib/scales-worker/response.rb
scales-worker-0.0.1.beta.2 lib/scales-worker/response.rb
scales-worker-0.0.1.beta.1 lib/scales-worker/response.rb