fix merge conflict from master
This commit is contained in:
68
library/server/wsf/src/response/wsf_cors_options_response.e
Normal file
68
library/server/wsf/src/response/wsf_cors_options_response.e
Normal file
@@ -0,0 +1,68 @@
|
||||
note
|
||||
description: "Response to an OPTIONS request, with Cross-Origin Resource Sharing support."
|
||||
author: "Olivier Ligt"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
|
||||
|
||||
class
|
||||
WSF_CORS_OPTIONS_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_RESPONSE_MESSAGE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; a_router: like router)
|
||||
do
|
||||
request := req
|
||||
router := a_router
|
||||
create header.make
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- Associated request
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Associated router
|
||||
|
||||
header: HTTP_HEADER
|
||||
-- Response' header
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.Ok)
|
||||
header.put_content_type ({HTTP_MIME_TYPES}.text_plain)
|
||||
header.put_current_date
|
||||
header.put_content_length (0)
|
||||
if attached request.http_access_control_request_headers as l_headers then
|
||||
header.put_access_control_allow_headers (l_headers)
|
||||
end
|
||||
l_methods := router.allowed_methods_for_request (request)
|
||||
if not l_methods.is_empty then
|
||||
header.put_allow (l_methods)
|
||||
header.put_access_control_allow_methods (l_methods)
|
||||
end
|
||||
res.put_header_text (header.string)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
make (a_file_name: READABLE_STRING_8)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
file_name := a_file_name
|
||||
base_name := basename (a_file_name)
|
||||
get_content_type
|
||||
@@ -28,6 +29,7 @@ feature {NONE} -- Initialization
|
||||
make_with_content_type (a_content_type: READABLE_STRING_8; a_filename: READABLE_STRING_8)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
file_name := a_filename
|
||||
base_name := basename (a_filename)
|
||||
content_type := a_content_type
|
||||
@@ -54,6 +56,14 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_base_name (n: like base_name)
|
||||
do
|
||||
base_name := n
|
||||
header.put_content_disposition ("attachment", "filename=%""+ n +"%"")
|
||||
ensure
|
||||
base_name_set: n.same_string (base_name)
|
||||
end
|
||||
|
||||
set_expires (t: INTEGER)
|
||||
do
|
||||
header.put_expires (t)
|
||||
@@ -91,7 +101,7 @@ feature -- Element change
|
||||
set_status_code (c: like status_code)
|
||||
-- Set `status_code' to `c'.
|
||||
require
|
||||
valid_status_code: status_code > 0
|
||||
valid_status_code: c > 0
|
||||
do
|
||||
status_code := c
|
||||
ensure
|
||||
@@ -207,8 +217,11 @@ feature -- Implementation: output
|
||||
f.close
|
||||
end
|
||||
|
||||
invariant
|
||||
status_code_set: status_code /= 0
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
make (a_file_name: READABLE_STRING_8)
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
file_name := a_file_name
|
||||
get_content_type
|
||||
initialize
|
||||
@@ -27,6 +28,7 @@ feature {NONE} -- Initialization
|
||||
make_with_content_type (a_content_type: READABLE_STRING_8; a_filename: READABLE_STRING_8)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
file_name := a_filename
|
||||
content_type := a_content_type
|
||||
initialize
|
||||
@@ -279,7 +281,7 @@ feature {NONE} -- Implementation: output
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description: "[
|
||||
This class is used to report a 501 not implemented
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_NOT_IMPLEMENTED_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_RESPONSE_MESSAGE
|
||||
|
||||
SHARED_HTML_ENCODER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST)
|
||||
do
|
||||
create header.make
|
||||
request := req
|
||||
end
|
||||
|
||||
feature -- Header
|
||||
|
||||
header: HTTP_HEADER
|
||||
-- Response' header
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- Associated request.
|
||||
|
||||
body: detachable READABLE_STRING_8
|
||||
-- Optional body
|
||||
-- Displayed as extra content
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_body (b: like body)
|
||||
-- Set `body' to `b'
|
||||
do
|
||||
body := b
|
||||
end
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
s: STRING
|
||||
h: like header
|
||||
do
|
||||
h := header
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
|
||||
|
||||
s := "Error 501 Not Implemented ! "
|
||||
s.append (request.request_uri)
|
||||
if attached body as b then
|
||||
s.append ("%N")
|
||||
s.append (b)
|
||||
s.append ("%N")
|
||||
end
|
||||
h.put_content_type_text_plain
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
res.flush
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -1041,6 +1041,13 @@ feature -- HTTP_*
|
||||
Result := wgi_request.http_transfer_encoding
|
||||
end
|
||||
|
||||
http_access_control_request_headers: detachable READABLE_STRING_8
|
||||
-- Indicates which headers will be used in the actual request
|
||||
-- as part of the preflight request
|
||||
do
|
||||
Result := wgi_request.http_access_control_request_headers
|
||||
end
|
||||
|
||||
feature -- Extra CGI environment variables
|
||||
|
||||
request_uri: READABLE_STRING_8
|
||||
|
||||
Reference in New Issue
Block a user