Sha256: fb682cca89d155269fc4e6abead9e3627522f36f7dee6168ec5e2a6b94272688

Contents?: true

Size: 539 Bytes

Versions: 25

Compression:

Stored size: 539 Bytes

Contents

module Restfully
  module HTTP
    module Headers
      def sanitize_http_headers(headers = {})
        sanitized_headers = {}
        headers.each do |key, value|
          sanitized_key = key.to_s.downcase.gsub(/[_-]/, ' ').split(' ').map{|word| word.capitalize}.join("-")
          sanitized_value = case value
          when Array 
            value.join(", ")
          else 
            value
          end
          sanitized_headers[sanitized_key] = sanitized_value
        end
        sanitized_headers
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
crohr-restfully-0.2.1 lib/restfully/http/headers.rb
crohr-restfully-0.2.2 lib/restfully/http/headers.rb
restfully-0.6.3 lib/restfully/http/headers.rb
restfully-0.6.2 lib/restfully/http/headers.rb
restfully-0.6.1 lib/restfully/http/headers.rb
restfully-0.6.0 lib/restfully/http/headers.rb
restfully-0.5.10 lib/restfully/http/headers.rb
restfully-0.5.9 lib/restfully/http/headers.rb
restfully-0.5.8 lib/restfully/http/headers.rb
restfully-0.5.7 lib/restfully/http/headers.rb
restfully-0.5.6 lib/restfully/http/headers.rb
restfully-0.5.5 lib/restfully/http/headers.rb
restfully-0.5.4 lib/restfully/http/headers.rb
restfully-0.5.3 lib/restfully/http/headers.rb
restfully-0.5.2 lib/restfully/http/headers.rb
restfully-0.5.1 lib/restfully/http/headers.rb
restfully-0.5.0 lib/restfully/http/headers.rb
restfully-0.4.1 lib/restfully/http/headers.rb
restfully-0.4.0 lib/restfully/http/headers.rb
restfully-0.3.2 lib/restfully/http/headers.rb