Fixed sending of chunk, especially the ending where there is an optional Trailer, and a mandatory final CRLF
Now put_chunk does not support anymore empty chunk, and thus does not call put_chunk_end if ever it is called with empty chunk content. Fixed the `transfered_content_length' when dealing with chunk transfert encoding
This commit is contained in:
@@ -13,6 +13,8 @@ note
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
EIS: "name=Hypertext Transfer Protocol -- HTTP/1.1 ", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616.html"
|
||||
EIS: "name=Chunked Transfer Coding", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1"
|
||||
|
||||
class
|
||||
WSF_RESPONSE
|
||||
@@ -222,11 +224,6 @@ feature -- Output operation
|
||||
l_chunk_size_line: STRING_8
|
||||
i: INTEGER
|
||||
do
|
||||
if s.is_empty then
|
||||
-- Should not occur due to precondition,
|
||||
-- but let's handle the case for backward compatibility reason.
|
||||
put_chunk_end
|
||||
else
|
||||
--| Remove all left '0'
|
||||
l_chunk_size_line := s.count.to_hex_string
|
||||
from
|
||||
@@ -245,21 +242,39 @@ feature -- Output operation
|
||||
l_chunk_size_line.append (a_extension)
|
||||
end
|
||||
l_chunk_size_line.append ({HTTP_CONSTANTS}.crlf)
|
||||
put_string (l_chunk_size_line)
|
||||
|
||||
|
||||
wgi_response.put_string (l_chunk_size_line)
|
||||
put_string (s)
|
||||
put_string ({HTTP_CONSTANTS}.crlf)
|
||||
wgi_response.put_string ({HTTP_CONSTANTS}.crlf)
|
||||
flush
|
||||
increment_transfered_content_length (s.count)
|
||||
end
|
||||
ensure
|
||||
transfered_content_length = old transfered_content_length + s.count.to_natural_64
|
||||
end
|
||||
|
||||
put_chunk_end
|
||||
-- Put end of chunked content
|
||||
-- without any optional trailer.
|
||||
do
|
||||
put_string ("0" + {HTTP_CONSTANTS}.crlf)
|
||||
wgi_response.put_string ("0")
|
||||
wgi_response.put_string ({HTTP_CONSTANTS}.crlf)
|
||||
-- No trailer
|
||||
wgi_response.put_string ({HTTP_CONSTANTS}.crlf)
|
||||
flush
|
||||
end
|
||||
|
||||
put_chunk_end_with_trailer (a_trailer: detachable READABLE_STRING_8)
|
||||
-- Put end of chunked content
|
||||
-- with optional trailer: *(entity-header CRLF)
|
||||
require
|
||||
a_trailer_well_formatted: (a_trailer /= Void and then not a_trailer.is_empty) implies a_trailer.ends_with ({HTTP_CONSTANTS}.crlf)
|
||||
do
|
||||
if a_trailer /= Void and then not a_trailer.is_empty then
|
||||
wgi_response.put_string (a_trailer)
|
||||
end
|
||||
wgi_response.put_string ({HTTP_CONSTANTS}.crlf)
|
||||
end
|
||||
|
||||
flush
|
||||
-- Flush if it makes sense
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user