mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Set @env[CONTENT_LENGTH] value as string. (#2549)
* Set @env[CONTENT_LENGTH] value as string. * Update tests. Update tests to reflect that CONTENT_LENGTH is now a string. Add change to History.md. * Update History.md Co-authored-by: Patrik Ragnarsson <patrik@starkast.net> Co-authored-by: Patrik Ragnarsson <patrik@starkast.net>
This commit is contained in:
parent
f5d98ff2a8
commit
b9a121be8f
3 changed files with 20 additions and 19 deletions
|
@ -1,7 +1,8 @@
|
||||||
## 5.2.1 / 2021-01-
|
## 5.2.1 / 2021-02-
|
||||||
|
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
* MiniSSL::Socket#write - use data.byteslice(wrote..-1) ([#2543])
|
* MiniSSL::Socket#write - use data.byteslice(wrote..-1) ([#2543])
|
||||||
|
* Set `@env[CONTENT_LENGTH]` value as string.
|
||||||
|
|
||||||
## 5.2.0 / 2021-01-27
|
## 5.2.0 / 2021-01-27
|
||||||
|
|
||||||
|
|
|
@ -374,7 +374,7 @@ module Puma
|
||||||
end
|
end
|
||||||
|
|
||||||
if decode_chunk(chunk)
|
if decode_chunk(chunk)
|
||||||
@env[CONTENT_LENGTH] = @chunked_content_length
|
@env[CONTENT_LENGTH] = @chunked_content_length.to_s
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -391,7 +391,7 @@ module Puma
|
||||||
@chunked_content_length = 0
|
@chunked_content_length = 0
|
||||||
|
|
||||||
if decode_chunk(body)
|
if decode_chunk(body)
|
||||||
@env[CONTENT_LENGTH] = @chunked_content_length
|
@env[CONTENT_LENGTH] = @chunked_content_length.to_s
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -518,7 +518,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_large_chunked_request
|
def test_large_chunked_request
|
||||||
|
@ -546,7 +546,7 @@ EOF
|
||||||
data = send_http_and_read request
|
data = send_http_and_read request
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal size, content_length
|
assert_equal size, Integer(content_length)
|
||||||
assert_equal request_body, body
|
assert_equal request_body, body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -569,7 +569,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_between_chunks
|
def test_chunked_request_pause_between_chunks
|
||||||
|
@ -590,7 +590,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_mid_count
|
def test_chunked_request_pause_mid_count
|
||||||
|
@ -611,7 +611,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_before_count_newline
|
def test_chunked_request_pause_before_count_newline
|
||||||
|
@ -632,7 +632,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_mid_value
|
def test_chunked_request_pause_mid_value
|
||||||
|
@ -653,7 +653,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_between_cr_lf_after_size_of_second_chunk
|
def test_chunked_request_pause_between_cr_lf_after_size_of_second_chunk
|
||||||
|
@ -683,7 +683,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal (part1 + 'b'), body
|
assert_equal (part1 + 'b'), body
|
||||||
assert_equal 4201, content_length
|
assert_equal "4201", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_between_closing_cr_lf
|
def test_chunked_request_pause_between_closing_cr_lf
|
||||||
|
@ -705,7 +705,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_pause_before_closing_cr_lf
|
def test_chunked_request_pause_before_closing_cr_lf
|
||||||
|
@ -727,7 +727,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal 'hello', body
|
assert_equal 'hello', body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_request_header_case
|
def test_chunked_request_header_case
|
||||||
|
@ -743,7 +743,7 @@ EOF
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chunked_keep_alive
|
def test_chunked_keep_alive
|
||||||
|
@ -761,7 +761,7 @@ EOF
|
||||||
|
|
||||||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
|
|
||||||
sock.close
|
sock.close
|
||||||
end
|
end
|
||||||
|
@ -789,7 +789,7 @@ EOF
|
||||||
h = header(sock)
|
h = header(sock)
|
||||||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
assert_equal true, last_crlf_written
|
assert_equal true, last_crlf_written
|
||||||
|
|
||||||
last_crlf_writer.join
|
last_crlf_writer.join
|
||||||
|
@ -801,7 +801,7 @@ EOF
|
||||||
|
|
||||||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
||||||
assert_equal "goodbye", body
|
assert_equal "goodbye", body
|
||||||
assert_equal 7, content_length
|
assert_equal "7", content_length
|
||||||
|
|
||||||
sock.close
|
sock.close
|
||||||
end
|
end
|
||||||
|
@ -823,7 +823,7 @@ EOF
|
||||||
h = header sock
|
h = header sock
|
||||||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
||||||
assert_equal "hello", body
|
assert_equal "hello", body
|
||||||
assert_equal 5, content_length
|
assert_equal "5", content_length
|
||||||
assert_equal "127.0.0.1", remote_addr
|
assert_equal "127.0.0.1", remote_addr
|
||||||
|
|
||||||
sock << "GET / HTTP/1.1\r\nX-Forwarded-For: 127.0.0.2\r\nConnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\n\r\n4\r\ngood\r\n3\r\nbye\r\n0\r\n\r\n"
|
sock << "GET / HTTP/1.1\r\nX-Forwarded-For: 127.0.0.2\r\nConnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\n\r\n4\r\ngood\r\n3\r\nbye\r\n0\r\n\r\n"
|
||||||
|
@ -833,7 +833,7 @@ EOF
|
||||||
|
|
||||||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], h
|
||||||
assert_equal "goodbye", body
|
assert_equal "goodbye", body
|
||||||
assert_equal 7, content_length
|
assert_equal "7", content_length
|
||||||
assert_equal "127.0.0.2", remote_addr
|
assert_equal "127.0.0.2", remote_addr
|
||||||
|
|
||||||
sock.close
|
sock.close
|
||||||
|
|
Loading…
Add table
Reference in a new issue