Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #859 from deepj/transfer-encoding

Constantize Transfer-Encoding header where possible
  • Loading branch information...
commit b526decedd2ae8458353896d9995ae59915d0459 2 parents a2fe30a + bde62cd
@spastorino spastorino authored
View
35 lib/rack.rb
@@ -25,23 +25,24 @@ def self.release
RELEASE
end
- HTTP_HOST = 'HTTP_HOST'.freeze
- HTTP_VERSION = 'HTTP_VERSION'.freeze
- HTTPS = 'HTTPS'.freeze
- PATH_INFO = 'PATH_INFO'.freeze
- REQUEST_METHOD = 'REQUEST_METHOD'.freeze
- REQUEST_PATH = 'REQUEST_PATH'.freeze
- SCRIPT_NAME = 'SCRIPT_NAME'.freeze
- QUERY_STRING = 'QUERY_STRING'.freeze
- SERVER_PROTOCOL = 'SERVER_PROTOCOL'.freeze
- SERVER_NAME = 'SERVER_NAME'.freeze
- SERVER_ADDR = 'SERVER_ADDR'.freeze
- SERVER_PORT = 'SERVER_PORT'.freeze
- CACHE_CONTROL = 'Cache-Control'.freeze
- CONTENT_LENGTH = 'Content-Length'.freeze
- CONTENT_TYPE = 'Content-Type'.freeze
- SET_COOKIE = 'Set-Cookie'.freeze
- HTTP_COOKIE = 'HTTP_COOKIE'.freeze
+ HTTP_HOST = 'HTTP_HOST'.freeze
+ HTTP_VERSION = 'HTTP_VERSION'.freeze
+ HTTPS = 'HTTPS'.freeze
+ PATH_INFO = 'PATH_INFO'.freeze
+ REQUEST_METHOD = 'REQUEST_METHOD'.freeze
+ REQUEST_PATH = 'REQUEST_PATH'.freeze
+ SCRIPT_NAME = 'SCRIPT_NAME'.freeze
+ QUERY_STRING = 'QUERY_STRING'.freeze
+ SERVER_PROTOCOL = 'SERVER_PROTOCOL'.freeze
+ SERVER_NAME = 'SERVER_NAME'.freeze
+ SERVER_ADDR = 'SERVER_ADDR'.freeze
+ SERVER_PORT = 'SERVER_PORT'.freeze
+ CACHE_CONTROL = 'Cache-Control'.freeze
+ CONTENT_LENGTH = 'Content-Length'.freeze
+ CONTENT_TYPE = 'Content-Type'.freeze
+ SET_COOKIE = 'Set-Cookie'.freeze
+ TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
+ HTTP_COOKIE = 'HTTP_COOKIE'.freeze
GET = 'GET'.freeze
POST = 'POST'.freeze
View
4 lib/rack/chunked.rb
@@ -57,11 +57,11 @@ def call(env)
if ! chunkable_version?(env[HTTP_VERSION]) ||
STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
headers[CONTENT_LENGTH] ||
- headers['Transfer-Encoding']
+ headers[TRANSFER_ENCODING]
[status, headers, body]
else
headers.delete(CONTENT_LENGTH)
- headers['Transfer-Encoding'] = 'chunked'
+ headers[TRANSFER_ENCODING] = 'chunked'
[status, headers, Body.new(body)]
end
end
View
2  lib/rack/content_length.rb
@@ -17,7 +17,7 @@ def call(env)
if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) &&
!headers[CONTENT_LENGTH] &&
- !headers['Transfer-Encoding'] &&
+ !headers[TRANSFER_ENCODING] &&
body.respond_to?(:to_ary)
obody = body
View
2  lib/rack/response.rb
@@ -21,7 +21,7 @@ class Response
attr_accessor :length
CHUNKED = 'chunked'.freeze
- TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
+
def initialize(body=[], status=200, header={})
@status = status.to_i
@header = Utils::HeaderHash.new.merge(header)
Please sign in to comment.
Something went wrong with that request. Please try again.