Merge pull request #128 from jocelyn/response_header
Extracting HTTP_HEADER_BUILDER from HTTP_HEADER Improving wsf session usage Various unicode related improvement for router and error library.
This commit is contained in:
@@ -45,7 +45,7 @@ feature {WSF_RESPONSE} -- Output
|
||||
req := request
|
||||
if attached req.raw_header_data as l_header then
|
||||
create s.make (l_header.count)
|
||||
s.append (l_header.to_string_8)
|
||||
s.append (l_header.to_string_8) -- Is valid as string 8, as ensured by req.raw_header_data
|
||||
s.append_character ('%N')
|
||||
else
|
||||
create s.make_empty
|
||||
@@ -99,7 +99,7 @@ feature {WSF_RESPONSE} -- Output
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -1287,41 +1287,43 @@ feature {NONE} -- Cookies
|
||||
local
|
||||
i,j,p,n: INTEGER
|
||||
l_cookies: like internal_cookies_table
|
||||
s32: READABLE_STRING_32
|
||||
k,v,s: STRING
|
||||
do
|
||||
l_cookies := internal_cookies_table
|
||||
if l_cookies = Void then
|
||||
create l_cookies.make_equal (0)
|
||||
if attached {WSF_STRING} meta_variable ({WSF_META_NAMES}.http_cookie) as val then
|
||||
s := val.value
|
||||
create l_cookies.make_equal (5)
|
||||
from
|
||||
n := s.count
|
||||
p := 1
|
||||
i := 1
|
||||
until
|
||||
p < 1
|
||||
loop
|
||||
i := s.index_of ('=', p)
|
||||
if i > 0 then
|
||||
j := s.index_of (';', i)
|
||||
if j = 0 then
|
||||
j := n + 1
|
||||
k := s.substring (p, i - 1)
|
||||
v := s.substring (i + 1, n)
|
||||
s32 := val.value
|
||||
if s32.is_valid_as_string_8 then
|
||||
s := s32.to_string_8
|
||||
from
|
||||
n := s.count
|
||||
p := 1
|
||||
i := 1
|
||||
until
|
||||
p < 1
|
||||
loop
|
||||
i := s.index_of ('=', p)
|
||||
if i > 0 then
|
||||
j := s.index_of (';', i)
|
||||
if j = 0 then
|
||||
j := n + 1
|
||||
k := s.substring (p, i - 1)
|
||||
v := s.substring (i + 1, n)
|
||||
|
||||
p := 0 -- force termination
|
||||
else
|
||||
k := s.substring (p, i - 1)
|
||||
v := s.substring (i + 1, j - 1)
|
||||
p := j + 1
|
||||
p := 0 -- force termination
|
||||
else
|
||||
k := s.substring (p, i - 1)
|
||||
v := s.substring (i + 1, j - 1)
|
||||
p := j + 1
|
||||
end
|
||||
k.left_adjust
|
||||
k.right_adjust
|
||||
add_value_to_table (k, v, l_cookies)
|
||||
end
|
||||
k.left_adjust
|
||||
k.right_adjust
|
||||
add_value_to_table (k, v, l_cookies)
|
||||
end
|
||||
end
|
||||
else
|
||||
create l_cookies.make_equal (0)
|
||||
end
|
||||
internal_cookies_table := l_cookies
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ feature {NONE} -- Initialization
|
||||
wres: detachable WSF_WGI_DELAYED_HEADER_RESPONSE
|
||||
do
|
||||
transfered_content_length := 0
|
||||
create header.make
|
||||
create internal_header.make
|
||||
wgi_response := r
|
||||
if attached {WSF_WGI_DELAYED_HEADER_RESPONSE} r as r_delayed then
|
||||
r_delayed.update_wsf_response (Current)
|
||||
@@ -53,7 +53,7 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
transfered_content_length := 0
|
||||
wgi_response := res.wgi_response
|
||||
header := res.header
|
||||
internal_header := res.internal_header
|
||||
set_status_code ({HTTP_STATUS_CODE}.ok) -- Default value
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ feature {WSF_RESPONSE, WSF_RESPONSE_EXPORTER} -- Properties
|
||||
wgi_response: WGI_RESPONSE
|
||||
-- Associated WGI_RESPONSE.
|
||||
|
||||
header: WSF_HEADER
|
||||
internal_header: WSF_HEADER
|
||||
-- Associated response header.
|
||||
|
||||
feature {WSF_RESPONSE_EXPORTER} -- Change
|
||||
@@ -158,7 +158,7 @@ feature {WSF_RESPONSE_EXPORTER} -- Header output operation
|
||||
-- commit status code and reason phrase
|
||||
wgi_response.set_status_code (status_code, status_reason_phrase)
|
||||
-- commit header text
|
||||
wgi_response.put_header_text (header.string)
|
||||
wgi_response.put_header_text (internal_header.string)
|
||||
end
|
||||
ensure
|
||||
status_committed: status_committed
|
||||
@@ -170,6 +170,26 @@ feature {WSF_RESPONSE_EXPORTER} -- Header output operation
|
||||
put_error ("Content already sent, new header text ignored!")
|
||||
end
|
||||
|
||||
feature -- Header access
|
||||
|
||||
header: HTTP_HEADER_MODIFIER
|
||||
-- Associated header builder interface.
|
||||
local
|
||||
res: like internal_response_header
|
||||
do
|
||||
res := internal_response_header
|
||||
if res = Void then
|
||||
create {WSF_RESPONSE_HEADER} res.make_with_response (Current)
|
||||
internal_response_header := res
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
feature {NONE} -- Header access
|
||||
|
||||
internal_response_header: detachable like header
|
||||
-- Cached version of `header'.
|
||||
|
||||
feature -- Header output operation
|
||||
|
||||
put_header_line (h: READABLE_STRING_8)
|
||||
@@ -181,7 +201,7 @@ feature -- Header output operation
|
||||
if header_committed then
|
||||
report_content_already_sent_and_header_ignored
|
||||
else
|
||||
header.put_header (h)
|
||||
internal_header.put_header (h)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -194,7 +214,7 @@ feature -- Header output operation
|
||||
if header_committed then
|
||||
report_content_already_sent_and_header_ignored
|
||||
else
|
||||
header.add_header (h)
|
||||
internal_header.add_header (h)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -209,7 +229,7 @@ feature -- Header output operation
|
||||
if header_committed then
|
||||
report_content_already_sent_and_header_ignored
|
||||
else
|
||||
header.put_raw_header_data (a_text)
|
||||
internal_header.put_raw_header_data (a_text)
|
||||
end
|
||||
ensure
|
||||
message_writable: message_writable
|
||||
@@ -227,7 +247,7 @@ feature -- Header output operation
|
||||
if header_committed then
|
||||
report_content_already_sent_and_header_ignored
|
||||
else
|
||||
header.append_raw_header_data (a_text)
|
||||
internal_header.append_raw_header_data (a_text)
|
||||
end
|
||||
ensure
|
||||
status_set: status_is_set
|
||||
@@ -496,7 +516,7 @@ feature -- Error reporting
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
64
library/server/wsf/src/wsf_response_header.e
Normal file
64
library/server/wsf/src/wsf_response_header.e
Normal file
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "[
|
||||
Interface to build the http header associated with WSF_RESPONSE.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_RESPONSE_HEADER
|
||||
|
||||
inherit
|
||||
HTTP_HEADER_MODIFIER
|
||||
|
||||
WSF_RESPONSE_EXPORTER -- to access WSF_RESPONSE.internal_header
|
||||
|
||||
create
|
||||
make_with_response
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_response (res: WSF_RESPONSE)
|
||||
do
|
||||
response := res
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
response: WSF_RESPONSE
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: INDEXABLE_ITERATION_CURSOR [READABLE_STRING_8]
|
||||
-- Fresh cursor associated with current structure.
|
||||
do
|
||||
Result := response.internal_header.new_cursor
|
||||
end
|
||||
|
||||
feature -- Header change: core
|
||||
|
||||
add_header (h: READABLE_STRING_8)
|
||||
-- Add header `h'
|
||||
-- if it already exists, there will be multiple header with same name
|
||||
-- which can also be valid
|
||||
do
|
||||
response.add_header_line (h)
|
||||
end
|
||||
|
||||
put_header (h: READABLE_STRING_8)
|
||||
-- Add header `h' or replace existing header of same header name
|
||||
do
|
||||
response.put_header_line (h)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
Reference in New Issue
Block a user