Extracting HTTP_HEADER_BUILDER from HTTP_HEADER
to provide useful interface on WSF_RESPONSE, and make WSF_SESSION easier to use.
This commit is contained in:
@@ -60,15 +60,15 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Cookie
|
||||
|
||||
apply_to (h: HTTP_HEADER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
apply_to (h: HTTP_HEADER_BUILDER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
local
|
||||
dt: detachable DATE_TIME
|
||||
l_domain: detachable READABLE_STRING_8
|
||||
do
|
||||
l_domain := a_request.server_name
|
||||
if l_domain.same_string ("localhost") then
|
||||
-- Due to limitation of specific handling of local cookies
|
||||
-- it is recommended to use Void or IP instead of "localhost"
|
||||
-- Due to limitation of specific handling of local cookies
|
||||
-- it is recommended to use Void or IP instead of "localhost"
|
||||
l_domain := Void
|
||||
end
|
||||
if is_destroyed then
|
||||
@@ -177,7 +177,7 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, 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
|
||||
|
||||
@@ -78,12 +78,21 @@ feature -- Control
|
||||
deferred
|
||||
end
|
||||
|
||||
apply_to (h: HTTP_HEADER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
apply_to (h: HTTP_HEADER_BUILDER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
-- Apply current session to header `h' for request `req' and optional path `a_path'.
|
||||
-- note: either use `apply_to' or `apply', not both.
|
||||
deferred
|
||||
end
|
||||
|
||||
apply (req: WSF_REQUEST; res: WSF_RESPONSE; a_path: detachable READABLE_STRING_8)
|
||||
-- Apply current session to response `res' for request `req' and optional path `a_path'.
|
||||
-- note: either use `apply' or `apply_to', not both.
|
||||
do
|
||||
apply_to (res.header, req, a_path)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, 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
|
||||
|
||||
@@ -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_BUILDER
|
||||
-- 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
|
||||
|
||||
63
library/server/wsf/src/wsf_response_header.e
Normal file
63
library/server/wsf/src/wsf_response_header.e
Normal file
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "Summary description for {WSF_RESPONSE_HEADER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_RESPONSE_HEADER
|
||||
|
||||
inherit
|
||||
HTTP_HEADER_BUILDER
|
||||
|
||||
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