First try to get a limited WGI_ and use WSF_ as default framework
This commit is contained in:
13
library/server/wsf/src/cgi_meta_names.e
Normal file
13
library/server/wsf/src/cgi_meta_names.e
Normal file
@@ -0,0 +1,13 @@
|
||||
note
|
||||
description: "Summary description for {WSF_META_NAMES}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CGI_META_NAMES
|
||||
|
||||
inherit
|
||||
WGI_META_NAMES
|
||||
|
||||
end
|
||||
143
library/server/wsf/src/request/value/wsf_multiple_string_value.e
Normal file
143
library/server/wsf/src/request/value/wsf_multiple_string_value.e
Normal file
@@ -0,0 +1,143 @@
|
||||
note
|
||||
description: "Summary description for {WSF_MULTIPLE_STRING_VALUE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_MULTIPLE_STRING_VALUE
|
||||
|
||||
inherit
|
||||
WSF_VALUE
|
||||
|
||||
ITERABLE [WSF_STRING_VALUE]
|
||||
|
||||
create
|
||||
make_with_value,
|
||||
make_with_array,
|
||||
make_with_string
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_value (a_value: WSF_VALUE)
|
||||
do
|
||||
name := a_value.name
|
||||
create {LINKED_LIST [WSF_STRING_VALUE]} string_values.make
|
||||
add_value (a_value)
|
||||
end
|
||||
|
||||
make_with_array (arr: ARRAY [WSF_VALUE])
|
||||
require
|
||||
arr_not_empty: not arr.is_empty
|
||||
all_same_name: across arr as c all c.item.name.same_string (arr[arr.lower].name) end
|
||||
local
|
||||
i,up: INTEGER
|
||||
do
|
||||
up := arr.upper
|
||||
i := arr.lower
|
||||
make_with_value (arr[i])
|
||||
from
|
||||
i := i + 1
|
||||
until
|
||||
i > up
|
||||
loop
|
||||
add_value (arr[i])
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
make_with_string (a_name: like name; a_string: READABLE_STRING_32)
|
||||
do
|
||||
make_with_value (create {WSF_STRING_VALUE}.make (a_name, a_string))
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_32
|
||||
|
||||
string_values: LIST [WSF_STRING_VALUE]
|
||||
|
||||
first_string_value: WSF_STRING_VALUE
|
||||
do
|
||||
Result := string_values.first
|
||||
end
|
||||
|
||||
feature -- Traversing
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_STRING_VALUE]
|
||||
do
|
||||
Result := string_values.new_cursor
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Does `a_other' represent the same string as `Current'?
|
||||
do
|
||||
if string_values.count = 1 then
|
||||
Result := first_string_value.same_string (a_other)
|
||||
end
|
||||
end
|
||||
|
||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
||||
do
|
||||
if string_values.count = 1 then
|
||||
Result := first_string_value.is_case_insensitive_equal (a_other)
|
||||
end
|
||||
end
|
||||
|
||||
as_string: STRING_32
|
||||
do
|
||||
if string_values.count = 1 then
|
||||
create Result.make_from_string (first_string_value)
|
||||
else
|
||||
create Result.make_from_string ("[")
|
||||
across
|
||||
string_values as c
|
||||
loop
|
||||
if Result.count > 1 then
|
||||
Result.append_character (',')
|
||||
end
|
||||
Result.append_string (c.item)
|
||||
end
|
||||
Result.append_character (']')
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
add_value (a_value: WSF_VALUE)
|
||||
require
|
||||
same_name: a_value.name.same_string (name)
|
||||
do
|
||||
if attached {WSF_STRING_VALUE} a_value as sval then
|
||||
add_string_value (sval)
|
||||
elseif attached {WSF_MULTIPLE_STRING_VALUE} a_value as slst then
|
||||
across
|
||||
slst as cur
|
||||
loop
|
||||
add_string_value (cur.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_string_value (s: WSF_STRING_VALUE)
|
||||
do
|
||||
string_values.extend (s)
|
||||
end
|
||||
|
||||
invariant
|
||||
string_values_not_empty: string_values.count >= 1
|
||||
|
||||
;note
|
||||
copyright: "2011-2011, 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
|
||||
71
library/server/wsf/src/request/value/wsf_string_value.e
Normal file
71
library/server/wsf/src/request/value/wsf_string_value.e
Normal file
@@ -0,0 +1,71 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STRING_VALUE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STRING_VALUE
|
||||
|
||||
inherit
|
||||
WSF_VALUE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
as_string: {READABLE_STRING_32, STRING_32}
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: READABLE_STRING_GENERAL; a_string: like string)
|
||||
do
|
||||
name := a_name.as_string_32
|
||||
string := a_string
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_32
|
||||
|
||||
string: READABLE_STRING_32
|
||||
|
||||
feature -- Helper
|
||||
|
||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Does `a_other' represent the same string as `Current'?
|
||||
do
|
||||
Result := string.same_string_general (a_other)
|
||||
end
|
||||
|
||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
||||
local
|
||||
v: like string
|
||||
do
|
||||
v := string
|
||||
if v = a_other then
|
||||
Result := True
|
||||
elseif v.is_valid_as_string_8 then
|
||||
Result := v.is_case_insensitive_equal (a_other)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
as_string: STRING_32
|
||||
do
|
||||
create Result.make_from_string (string)
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2011, 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
|
||||
59
library/server/wsf/src/request/wsf_value.e
Normal file
59
library/server/wsf/src/request/wsf_value.e
Normal file
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {WSF_VALUE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_VALUE
|
||||
|
||||
inherit
|
||||
DEBUG_OUTPUT
|
||||
|
||||
convert
|
||||
as_string: {READABLE_STRING_32, STRING_32}
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_32
|
||||
-- Parameter name
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Does `a_other' represent the same string as `Current'?
|
||||
deferred
|
||||
end
|
||||
|
||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
debug_output: STRING
|
||||
-- String that should be displayed in debugger to represent `Current'.
|
||||
do
|
||||
create Result.make_from_string (name.as_string_8 + "=" + as_string.as_string_8)
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
as_string: STRING_32
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, 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
|
||||
66
library/server/wsf/src/support/wsf_error.e
Normal file
66
library/server/wsf/src/support/wsf_error.e
Normal file
@@ -0,0 +1,66 @@
|
||||
note
|
||||
description: "Summary description for {WSF_ERROR}."
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_ERROR
|
||||
|
||||
inherit
|
||||
ERROR
|
||||
|
||||
HTTP_STATUS_CODE_MESSAGES
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_code: INTEGER)
|
||||
do
|
||||
code := a_code
|
||||
name := "HTTP Error"
|
||||
if attached http_status_code_message (a_code) as m then
|
||||
name := m
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
code: INTEGER
|
||||
|
||||
name: STRING
|
||||
|
||||
message: detachable STRING_32
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_message (m: like message)
|
||||
-- Set `message' to `m'
|
||||
require
|
||||
m_attached: m /= Void
|
||||
do
|
||||
message := m
|
||||
end
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
process (a_visitor: ERROR_VISITOR)
|
||||
-- Process Current using `a_visitor'.
|
||||
do
|
||||
a_visitor.process_error (Current)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, 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
|
||||
454
library/server/wsf/src/support/wsf_header.e
Normal file
454
library/server/wsf/src/support/wsf_header.e
Normal file
@@ -0,0 +1,454 @@
|
||||
note
|
||||
description: "[
|
||||
The class provides an easy way to build HTTP header.
|
||||
|
||||
You will also find some helper feature to help coding most common usage
|
||||
|
||||
Please, have a look at constants classes such as
|
||||
HTTP_MIME_TYPES
|
||||
HTTP_HEADER_NAMES
|
||||
HTTP_STATUS_CODE
|
||||
HTTP_REQUEST_METHODS
|
||||
(or HTTP_CONSTANTS which groups them for convenience)
|
||||
|
||||
Note the return status code is not part of the HTTP header
|
||||
However you can set the "Status: " header line if you want
|
||||
]"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_HEADER
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
HTTP_STATUS_CODE_MESSAGES --| useful for `put_status'
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_count
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize current
|
||||
do
|
||||
make_with_count (3)
|
||||
end
|
||||
|
||||
make_with_count (n: INTEGER)
|
||||
-- Make with a capacity of `n' header entries
|
||||
do
|
||||
create {ARRAYED_LIST [READABLE_STRING_8]} headers.make (n)
|
||||
end
|
||||
|
||||
feature -- Recycle
|
||||
|
||||
recycle
|
||||
-- Recycle current object
|
||||
do
|
||||
headers.wipe_out
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
headers: LIST [READABLE_STRING_8]
|
||||
-- Header's lines
|
||||
|
||||
string: STRING
|
||||
-- String representation of the headers
|
||||
local
|
||||
l_headers: like headers
|
||||
do
|
||||
create Result.make (32)
|
||||
l_headers := headers
|
||||
if l_headers.is_empty then
|
||||
put_content_type_text_html -- See if this make sense to define a default content-type
|
||||
else
|
||||
from
|
||||
l_headers.start
|
||||
until
|
||||
l_headers.after
|
||||
loop
|
||||
append_line_to (l_headers.item, Result)
|
||||
l_headers.forth
|
||||
end
|
||||
end
|
||||
append_end_of_line_to (Result)
|
||||
end
|
||||
|
||||
feature -- Header change: general
|
||||
|
||||
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
|
||||
require
|
||||
h_not_empty: not h.is_empty
|
||||
do
|
||||
headers.force (h)
|
||||
end
|
||||
|
||||
put_header (h: READABLE_STRING_8)
|
||||
-- Add header `h' or replace existing header of same header name
|
||||
require
|
||||
h_not_empty: not h.is_empty
|
||||
do
|
||||
force_header_by_name (header_name (h), h)
|
||||
end
|
||||
|
||||
add_header_key_value (k,v: READABLE_STRING_8)
|
||||
-- Add header `k:v', or replace existing header of same header name/key
|
||||
do
|
||||
add_header (k + colon_space + v)
|
||||
end
|
||||
|
||||
put_header_key_value (k,v: READABLE_STRING_8)
|
||||
-- Add header `k:v', or replace existing header of same header name/key
|
||||
do
|
||||
put_header (k + colon_space + v)
|
||||
end
|
||||
|
||||
feature -- Status related
|
||||
|
||||
put_status (c: INTEGER)
|
||||
-- Put "Status: " header
|
||||
-- Rarely used
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
create s.make_from_string (c.out)
|
||||
if attached http_status_code_message (c) as msg then
|
||||
s.append_character (' ')
|
||||
s.append (msg)
|
||||
end
|
||||
put_header_key_value ("Status", s)
|
||||
end
|
||||
|
||||
feature -- Content related header
|
||||
|
||||
put_content_type (t: READABLE_STRING_8)
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t)
|
||||
end
|
||||
|
||||
add_content_type (t: READABLE_STRING_8)
|
||||
-- same as `put_content_type', but allow multiple definition of "Content-Type"
|
||||
do
|
||||
add_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t)
|
||||
end
|
||||
|
||||
put_content_type_with_name (t: READABLE_STRING_8; n: READABLE_STRING_8)
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t + "; name=%"" + n + "%"")
|
||||
end
|
||||
|
||||
add_content_type_with_name (t: READABLE_STRING_8; n: READABLE_STRING_8)
|
||||
-- same as `put_content_type_with_name', but allow multiple definition of "Content-Type"
|
||||
do
|
||||
add_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t + "; name=%"" + n + "%"")
|
||||
end
|
||||
|
||||
put_content_length (n: INTEGER)
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_length, n.out)
|
||||
end
|
||||
|
||||
put_content_transfer_encoding (a_mechanism: READABLE_STRING_8)
|
||||
-- Put "Content-Transfer-Encoding" header with for instance "binary"
|
||||
--| encoding := "Content-Transfer-Encoding" ":" mechanism
|
||||
--|
|
||||
--| mechanism := "7bit" ; case-insensitive
|
||||
--| / "quoted-printable"
|
||||
--| / "base64"
|
||||
--| / "8bit"
|
||||
--| / "binary"
|
||||
--| / x-token
|
||||
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_transfer_encoding, a_mechanism)
|
||||
end
|
||||
|
||||
put_transfer_encoding (a_enc: READABLE_STRING_8)
|
||||
-- Put "Transfer-Encoding" header with for instance "chunked"
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_transfer_encoding, a_enc)
|
||||
end
|
||||
|
||||
put_transfer_encoding_chunked
|
||||
-- Put "Transfer-Encoding: chunked" header
|
||||
do
|
||||
put_transfer_encoding ("chunked")
|
||||
end
|
||||
|
||||
put_content_disposition (a_type: READABLE_STRING_8; a_params: detachable READABLE_STRING_8)
|
||||
-- Put "Content-Disposition" header
|
||||
--| See RFC2183
|
||||
--| disposition := "Content-Disposition" ":"
|
||||
--| disposition-type
|
||||
--| *(";" disposition-parm)
|
||||
--| disposition-type := "inline"
|
||||
--| / "attachment"
|
||||
--| / extension-token
|
||||
--| ; values are not case-sensitive
|
||||
--| disposition-parm := filename-parm
|
||||
--| / creation-date-parm
|
||||
--| / modification-date-parm
|
||||
--| / read-date-parm
|
||||
--| / size-parm
|
||||
--| / parameter
|
||||
--| filename-parm := "filename" "=" value
|
||||
--| creation-date-parm := "creation-date" "=" quoted-date-time
|
||||
--| modification-date-parm := "modification-date" "=" quoted-date-time
|
||||
--| read-date-parm := "read-date" "=" quoted-date-time
|
||||
--| size-parm := "size" "=" 1*DIGIT
|
||||
--| quoted-date-time := quoted-string
|
||||
--| ; contents MUST be an RFC 822 `date-time'
|
||||
--| ; numeric timezones (+HHMM or -HHMM) MUST be used
|
||||
do
|
||||
if a_params /= Void then
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_disposition, a_type + semi_colon_space + a_params)
|
||||
else
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_disposition, a_type)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Content-type helpers
|
||||
|
||||
put_content_type_text_css do put_content_type ({HTTP_MIME_TYPES}.text_css) end
|
||||
put_content_type_text_csv do put_content_type ({HTTP_MIME_TYPES}.text_csv) end
|
||||
put_content_type_text_html do put_content_type ({HTTP_MIME_TYPES}.text_html) end
|
||||
put_content_type_text_javascript do put_content_type ({HTTP_MIME_TYPES}.text_javascript) end
|
||||
put_content_type_text_json do put_content_type ({HTTP_MIME_TYPES}.text_json) end
|
||||
put_content_type_text_plain do put_content_type ({HTTP_MIME_TYPES}.text_plain) end
|
||||
put_content_type_text_xml do put_content_type ({HTTP_MIME_TYPES}.text_xml) end
|
||||
|
||||
put_content_type_application_json do put_content_type ({HTTP_MIME_TYPES}.application_json) end
|
||||
put_content_type_application_javascript do put_content_type ({HTTP_MIME_TYPES}.application_javascript) end
|
||||
put_content_type_application_zip do put_content_type ({HTTP_MIME_TYPES}.application_zip) end
|
||||
|
||||
put_content_type_image_gif do put_content_type ({HTTP_MIME_TYPES}.image_gif) end
|
||||
put_content_type_image_png do put_content_type ({HTTP_MIME_TYPES}.image_png) end
|
||||
put_content_type_image_jpg do put_content_type ({HTTP_MIME_TYPES}.image_jpg) end
|
||||
put_content_type_image_svg_xml do put_content_type ({HTTP_MIME_TYPES}.image_svg_xml) end
|
||||
|
||||
put_content_type_message_http do put_content_type ({HTTP_MIME_TYPES}.message_http) end
|
||||
|
||||
put_content_type_multipart_mixed do put_content_type ({HTTP_MIME_TYPES}.multipart_mixed) end
|
||||
put_content_type_multipart_alternative do put_content_type ({HTTP_MIME_TYPES}.multipart_alternative) end
|
||||
put_content_type_multipart_related do put_content_type ({HTTP_MIME_TYPES}.multipart_related) end
|
||||
put_content_type_multipart_form_data do put_content_type ({HTTP_MIME_TYPES}.multipart_form_data) end
|
||||
put_content_type_multipart_signed do put_content_type ({HTTP_MIME_TYPES}.multipart_signed) end
|
||||
put_content_type_multipart_encrypted do put_content_type ({HTTP_MIME_TYPES}.multipart_encrypted) end
|
||||
|
||||
feature -- Date
|
||||
|
||||
put_date (s: READABLE_STRING_8)
|
||||
-- Put "Date: " header
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_date, s)
|
||||
end
|
||||
|
||||
put_current_date
|
||||
-- Put current date time with "Date" header
|
||||
do
|
||||
put_utc_date (create {DATE_TIME}.make_now_utc)
|
||||
end
|
||||
|
||||
put_utc_date (dt: DATE_TIME)
|
||||
-- Put UTC date time `dt' with "Date" header
|
||||
do
|
||||
put_date (dt.formatted_out ("ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2") + " GMT")
|
||||
end
|
||||
|
||||
feature -- Others
|
||||
|
||||
put_expires (n: INTEGER)
|
||||
do
|
||||
put_header_key_value ("Expires", n.out)
|
||||
end
|
||||
|
||||
put_cache_control (s: READABLE_STRING_8)
|
||||
-- `s' could be for instance "no-cache, must-revalidate"
|
||||
do
|
||||
put_header_key_value ("Cache-Control", s)
|
||||
end
|
||||
|
||||
put_pragma (s: READABLE_STRING_8)
|
||||
do
|
||||
put_header_key_value ("Pragma", s)
|
||||
end
|
||||
|
||||
put_pragma_no_cache
|
||||
do
|
||||
put_pragma ("no-cache")
|
||||
end
|
||||
|
||||
feature -- Redirection
|
||||
|
||||
put_location (a_location: READABLE_STRING_8)
|
||||
-- Tell the client the new location `a_location'
|
||||
require
|
||||
a_location_valid: not a_location.is_empty
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_location, a_location)
|
||||
end
|
||||
|
||||
put_refresh (a_location: READABLE_STRING_8; a_timeout_in_seconds: INTEGER)
|
||||
-- Tell the client to refresh page with `a_location' after `a_timeout_in_seconds' in seconds
|
||||
require
|
||||
a_location_valid: not a_location.is_empty
|
||||
do
|
||||
put_header_key_value ({HTTP_HEADER_NAMES}.header_refresh, a_timeout_in_seconds.out + "; url=" + a_location)
|
||||
end
|
||||
|
||||
feature -- Cookie
|
||||
|
||||
put_cookie (key, value: READABLE_STRING_8; expiration, path, domain, secure: detachable READABLE_STRING_8)
|
||||
-- Set a cookie on the client's machine
|
||||
-- with key 'key' and value 'value'.
|
||||
require
|
||||
make_sense: (key /= Void and value /= Void) and then (not key.is_empty and not value.is_empty)
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
s := {HTTP_HEADER_NAMES}.header_set_cookie + colon_space + key + "=" + value
|
||||
if expiration /= Void then
|
||||
s.append ("; expires=" + expiration)
|
||||
end
|
||||
if path /= Void then
|
||||
s.append ("; path=" + path)
|
||||
end
|
||||
if domain /= Void then
|
||||
s.append ("; domain=" + domain)
|
||||
end
|
||||
if secure /= Void then
|
||||
s.append ("; secure=" + secure)
|
||||
end
|
||||
add_header (s)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_header_named (a_name: READABLE_STRING_8): BOOLEAN
|
||||
-- Has header item for `n'?
|
||||
local
|
||||
c: like headers.new_cursor
|
||||
n: INTEGER
|
||||
l_line: READABLE_STRING_8
|
||||
do
|
||||
from
|
||||
n := a_name.count
|
||||
c := headers.new_cursor
|
||||
until
|
||||
c.after or Result
|
||||
loop
|
||||
l_line := c.item
|
||||
if l_line.starts_with (a_name) then
|
||||
if l_line.valid_index (n + 1) then
|
||||
Result := l_line [n + 1] = ':'
|
||||
end
|
||||
end
|
||||
c.forth
|
||||
end
|
||||
end
|
||||
|
||||
has_content_length: BOOLEAN
|
||||
-- Has header "content_length"
|
||||
do
|
||||
Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_length)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Header
|
||||
|
||||
force_header_by_name (n: detachable READABLE_STRING_8; h: READABLE_STRING_8)
|
||||
-- Add header `h' or replace existing header of same header name `n'
|
||||
require
|
||||
h_has_name_n: (n /= Void and attached header_name (h) as hn) implies n.same_string (hn)
|
||||
local
|
||||
l_headers: like headers
|
||||
do
|
||||
if n /= Void then
|
||||
from
|
||||
l_headers := headers
|
||||
l_headers.start
|
||||
until
|
||||
l_headers.after or l_headers.item.starts_with (n)
|
||||
loop
|
||||
l_headers.forth
|
||||
end
|
||||
if not l_headers.after then
|
||||
l_headers.replace (h)
|
||||
else
|
||||
add_header (h)
|
||||
end
|
||||
else
|
||||
add_header (h)
|
||||
end
|
||||
end
|
||||
|
||||
header_name (h: READABLE_STRING_8): detachable READABLE_STRING_8
|
||||
-- If any, header's name with colon
|
||||
--| ex: for "Foo-bar: something", this will return "Foo-bar:"
|
||||
local
|
||||
s: detachable STRING_8
|
||||
i,n: INTEGER
|
||||
c: CHARACTER
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := h.count
|
||||
create s.make (10)
|
||||
until
|
||||
i > n or c = ':' or s = Void
|
||||
loop
|
||||
c := h[i]
|
||||
inspect c
|
||||
when ':' then
|
||||
s.extend (c)
|
||||
when '-', 'a' .. 'z', 'A' .. 'Z' then
|
||||
s.extend (c)
|
||||
else
|
||||
s := Void
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
Result := s
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
append_line_to (s: READABLE_STRING_8; h: like string)
|
||||
do
|
||||
h.append_string (s)
|
||||
append_end_of_line_to (h)
|
||||
end
|
||||
|
||||
append_end_of_line_to (h: like string)
|
||||
do
|
||||
h.append_character ('%R')
|
||||
h.append_character ('%N')
|
||||
end
|
||||
|
||||
feature {NONE} -- Constants
|
||||
|
||||
colon_space: STRING = ": "
|
||||
semi_colon_space: STRING = "; "
|
||||
|
||||
note
|
||||
copyright: "2011-2011, 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
|
||||
32
library/server/wsf/src/wsf_application.e
Normal file
32
library/server/wsf/src/wsf_application.e
Normal file
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_APPLICATION
|
||||
|
||||
inherit
|
||||
WGI_APPLICATION
|
||||
rename
|
||||
execute as wgi_execute
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the request
|
||||
-- See `req.input' for input stream
|
||||
-- `req.meta_variables' for the CGI meta variable
|
||||
-- and `res' for output buffer
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- WGI Execution
|
||||
|
||||
wgi_execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
end
|
||||
1486
library/server/wsf/src/wsf_request.e
Normal file
1486
library/server/wsf/src/wsf_request.e
Normal file
File diff suppressed because it is too large
Load Diff
164
library/server/wsf/src/wsf_response.e
Normal file
164
library/server/wsf/src/wsf_response.e
Normal file
@@ -0,0 +1,164 @@
|
||||
note
|
||||
description: "[
|
||||
Summary description for {WSF_RESPONSE}.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_RESPONSE
|
||||
|
||||
create {WSF_APPLICATION}
|
||||
make_from_wgi
|
||||
|
||||
convert
|
||||
make_from_wgi ({WGI_RESPONSE_BUFFER})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_from_wgi (r: WGI_RESPONSE_BUFFER)
|
||||
do
|
||||
wgi_response := r
|
||||
end
|
||||
|
||||
wgi_response: WGI_RESPONSE_BUFFER
|
||||
|
||||
--feature {WSF_APPLICATION} -- Commit
|
||||
|
||||
-- commit
|
||||
-- -- Commit the current response
|
||||
-- do
|
||||
-- wgi_response.commit
|
||||
-- ensure
|
||||
-- status_is_set: status_is_set
|
||||
-- header_committed: header_committed
|
||||
-- message_committed: message_committed
|
||||
-- end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
header_committed: BOOLEAN
|
||||
-- Header committed?
|
||||
do
|
||||
Result := wgi_response.header_committed
|
||||
end
|
||||
|
||||
message_committed: BOOLEAN
|
||||
-- Message committed?
|
||||
do
|
||||
Result := wgi_response.message_committed
|
||||
end
|
||||
|
||||
message_writable: BOOLEAN
|
||||
-- Can message be written?
|
||||
do
|
||||
Result := wgi_response.message_writable
|
||||
end
|
||||
|
||||
--feature {WGI_RESPONSE_BUFFER} -- Core output operation
|
||||
|
||||
-- write (s: READABLE_STRING_8)
|
||||
-- -- Send the string `s'
|
||||
-- -- this can be used for header and body
|
||||
-- do
|
||||
-- wgi_response.write (s)
|
||||
-- end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
status_is_set: BOOLEAN
|
||||
-- Is status set?
|
||||
do
|
||||
Result := wgi_response.status_is_set
|
||||
end
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set response status code
|
||||
-- Should be done before sending any data back to the client
|
||||
require
|
||||
status_not_set: not status_is_set
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
wgi_response.set_status_code (a_code)
|
||||
ensure
|
||||
status_code_set: status_code = a_code
|
||||
status_set: status_is_set
|
||||
end
|
||||
|
||||
status_code: INTEGER
|
||||
-- Response status
|
||||
do
|
||||
Result := wgi_response.status_code
|
||||
end
|
||||
|
||||
feature -- Header output operation
|
||||
|
||||
write_headers_string (a_headers: READABLE_STRING_8)
|
||||
require
|
||||
status_set: status_is_set
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
wgi_response.write_headers_string (a_headers)
|
||||
ensure
|
||||
status_set: status_is_set
|
||||
header_committed: header_committed
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
-- Send headers with status `a_status', and headers from `a_headers'
|
||||
require
|
||||
status_not_set: not status_is_set
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
wgi_response.write_header (a_status_code, a_headers)
|
||||
ensure
|
||||
header_committed: header_committed
|
||||
status_set: status_is_set
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
feature -- Output operation
|
||||
|
||||
write_string (s: READABLE_STRING_8)
|
||||
-- Send the string `s'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_string (s)
|
||||
end
|
||||
|
||||
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_substring (s, a_begin_index, a_end_index)
|
||||
end
|
||||
|
||||
write_file_content (fn: READABLE_STRING_8)
|
||||
-- Send the content of file `fn'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_file_content (fn)
|
||||
end
|
||||
|
||||
flush
|
||||
-- Flush if it makes sense
|
||||
do
|
||||
wgi_response.flush
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, 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
|
||||
20
library/server/wsf/wsf-safe.ecf
Normal file
20
library/server/wsf/wsf-safe.ecf
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="wsf" uuid="A37CE5AA-4D2A-4441-BC6A-0A1D7EC49647" library_target="wsf">
|
||||
<target name="wsf">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="ewsgi" location="..\ewsgi\ewsgi-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="error" location="..\..\error\error-safe.ecf"/>
|
||||
<library name="http" location="..\..\protocol\http\http-safe.ecf"/>
|
||||
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
16
library/server/wsf/wsf.ecf
Normal file
16
library/server/wsf/wsf.ecf
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="wsf" uuid="A37CE5AA-4D2A-4441-BC6A-0A1D7EC49647" library_target="wsf">
|
||||
<target name="wsf">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
|
||||
</option>
|
||||
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||
<cluster name="src" location="." recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
Reference in New Issue
Block a user