Merge remote-tracking branch 'jocelyn/flexible_response' into cors

Conflicts:
	examples/filter/filter-safe.ecf
	examples/filter/src/filter_server.e
	library/network/protocol/http/src/http_header.e
	library/server/wsf/src/wsf_response.e
This commit is contained in:
Olivier Ligot
2013-03-15 13:33:13 +01:00
370 changed files with 9238 additions and 35495 deletions

View File

@@ -27,6 +27,8 @@ feature -- Status
error_occurred: BOOLEAN
-- Error occurred during request
error_message: detachable READABLE_STRING_8
feature {HTTP_CLIENT_REQUEST} -- Status setting
set_error_occurred (b: BOOLEAN)
@@ -35,6 +37,13 @@ feature {HTTP_CLIENT_REQUEST} -- Status setting
error_occurred := b
end
set_error_message (m: READABLE_STRING_8)
-- Set `error_message' to `m'
do
set_error_occurred (True)
error_message := m
end
feature -- Access
url: STRING_8

View File

@@ -215,7 +215,7 @@ feature -- Execution
Result.status := response_status_code (curl_easy, curl_handle)
set_header_and_body_to (l_curl_string.string, Result)
else
Result.set_error_occurred (True)
Result.set_error_message ("Error: cURL Error[" + l_result.out + "]")
Result.status := response_status_code (curl_easy, curl_handle)
end
@@ -225,10 +225,10 @@ feature -- Execution
curl_easy.cleanup (curl_handle)
else
create Result.make (url)
Result.set_error_occurred (True)
Result.set_error_message ("Error: internal error")
end
--| Remaining cleaning
--| Remaining cleaning
if l_form /= Void then
l_form.dispose
end
@@ -339,7 +339,11 @@ feature {NONE} -- Implementation
--| ex: HTTP/1.1 200 OK%R%N
l_start := l_start + 2
end
if l_start < a_source.count and then a_source[l_start] = '%R' and a_source[l_start + 1] = '%N' then
if l_start = 0 or else
(l_start < a_source.count and then
a_source[l_start] = '%R' and a_source[l_start + 1] = '%N'
)
then
res.set_body (a_source)
else
pos := a_source.substring_index ("%R%N%R%N", l_start)

View File

@@ -1,5 +1,5 @@
<?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="test_http_client" uuid="920E5C50-41E1-4DAC-8D48-D9C860E49228">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="test_http_client" uuid="920E5C50-41E1-4DAC-8D48-D9C860E49228">
<target name="test_http_client">
<root class="TEST" feature="make"/>
<file_rule>

View File

@@ -48,7 +48,7 @@ feature -- Test routines
res: HTTP_CLIENT_RESPONSE
h: STRING
do
create res.make
create res.make ("http://example.com/")
create h.make_empty
h.append ("normal: NORMAL%R%N")
h.append ("concat: ABC%R%N")

View File

@@ -12,6 +12,10 @@
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<cluster name="src" location=".\" recursive="true"/>
<cluster name="src" location=".\" recursive="true">
<file_rule>
<exclude>/tests$</exclude>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -12,7 +12,11 @@
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<cluster name="src" location=".\" recursive="true"/>
<cluster name="src" location=".\" recursive="true">
<file_rule>
<exclude>/tests$</exclude>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -0,0 +1,831 @@
note
description: "[
Summary description for {HTTP_DATE}.
HTTP-date = rfc1123-date | rfc850-date | asctime-date
rfc1123-date = wkday "," SP date1 SP time SP "GMT"
rfc850-date = weekday "," SP date2 SP time SP "GMT"
asctime-date = wkday SP date3 SP time SP 4DIGIT
date1 = 2DIGIT SP month SP 4DIGIT
; day month year (e.g., 02 Jun 1982)
date2 = 2DIGIT "-" month "-" 2DIGIT
; day-month-year (e.g., 02-Jun-82)
date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
; month day (e.g., Jun 2)
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; 00:00:00 - 23:59:59
wkday = "Mon" | "Tue" | "Wed"
| "Thu" | "Fri" | "Sat" | "Sun"
weekday = "Monday" | "Tuesday" | "Wednesday"
| "Thursday" | "Friday" | "Saturday" | "Sunday"
month = "Jan" | "Feb" | "Mar" | "Apr"
| "May" | "Jun" | "Jul" | "Aug"
| "Sep" | "Oct" | "Nov" | "Dec"
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=RFC2616", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html"
class
HTTP_DATE
inherit
DEBUG_OUTPUT
create
make_from_timestamp,
make_from_string,
make_from_date_time
feature {NONE} -- Initialization
make_from_timestamp (n: INTEGER_64)
-- Build from unix timestamp `n'
do
internal_timestamp := n
--| FIXME: find workaround when `n' is not INTEGER_32
create date_time.make_from_epoch (n.as_integer_32)
end
make_from_string (s: READABLE_STRING_8)
-- Create from string representation `s'
-- Supports: RFC 1123 and RFC 850
-- Tolerant with: GMT+offset and GMT-offset
--| Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
--| Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
do
if attached string_to_date_time (s) as dt then
date_time := dt
elseif attached ansi_c_string_to_date_time (s) as dt then
date_time := dt
else
has_error := True
date_time := epoch
end
end
make_from_date_time (dt: DATE_TIME)
-- Build from date `dt'
do
date_time := dt
end
feature -- Access
has_error: BOOLEAN
-- Error occurred during creation with `make_from_string'?
date_time: DATE_TIME
-- Associated Date time.
string: STRING
-- String representation recommended for HTTP date.
--| Sun, 06 Nov 1994 08:49:37 GMT
do
Result := rfc1123_string
end
timestamp: INTEGER_64
-- Unix timestamp.
do
Result := internal_timestamp
if Result = 0 then
Result := date_time.definite_duration (epoch).seconds_count
internal_timestamp := Result
end
end
feature {NONE} -- Internal
epoch: DATE_TIME
once ("THREAD")
create Result.make_from_epoch (0)
end
internal_timestamp: like timestamp
internal_rfc1123_string: detachable STRING
feature -- Conversion to string
yyyy_mmm_dd_string: STRING
-- String representation YYYY mmm dd
-- 2012 Dec 25
do
create Result.make (11)
append_date_time_to_yyyy_mmm_dd_string (date_time, Result)
end
rfc1123_string: STRING
-- String representation following RFC 1123.
--| Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
local
s: like internal_rfc1123_string
do
s := internal_rfc1123_string
if s = Void then
create s.make (32)
append_date_time_to_rfc1123_string (date_time, s)
internal_rfc1123_string := s
end
Result := s
end
rfc850_string: STRING
-- String representation following RFC 850
do
create Result.make (32)
append_date_time_to_rfc850_string (date_time, Result)
end
ansi_c_string: STRING
-- ANSI C's asctime() format
do
create Result.make (32)
append_date_time_to_ansi_c_string (date_time, Result)
end
feature -- Conversion into string
append_date_time_to_yyyy_mmm_dd_string (dt: DATE_TIME; s: STRING)
do
s.append_integer (dt.year) -- yyyy
s.append_character (' ') -- ' '
append_month_mmm_to (dt.month, s) -- mmm
s.append_character (' ') -- ' '
append_2_digits_integer_to (dt.day, s) -- dd
end
append_date_time_to_rfc1123_string (dt: DATE_TIME; s: STRING)
do
append_day_ddd_to (dt.date.day_of_the_week, s) -- ddd
s.append_character (',') -- ','
s.append_character (' ') -- SPace
append_2_digits_integer_to (dt.day, s) -- dd
s.append_character (' ') -- SPace
append_month_mmm_to (dt.month, s) -- mmm
s.append_character (' ') -- SPace
s.append_integer (dt.year) -- yyyy
s.append_character (' ') -- SPace
append_2_digits_time_to (dt.time, s) -- hh:mi:ss
s.append (" GMT") -- SPace + GMT
end
append_date_time_to_rfc850_string (dt: DATE_TIME; s: STRING)
do
append_day_name_to (dt.date.day_of_the_week, s) -- mmm
s.append_character (',') -- ,
s.append_character (' ') -- SPace
append_2_digits_integer_to (dt.day, s) -- dd
s.append_character ('-') -- '-'
append_month_mmm_to (dt.month, s) -- mmm
s.append_character ('-') -- '-'
s.append_integer (dt.year \\ 100) -- yy
s.append_character (' ') -- SPace
append_2_digits_time_to (dt.time, s) -- hh:mi:ss
s.append (" GMT") -- SPace + GMT
end
append_date_time_to_ansi_c_string (dt: DATE_TIME; s: STRING)
--| Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
do
append_day_ddd_to (dt.date.day_of_the_week, s) -- ddd
s.append_character (' ') -- SP
append_month_mmm_to (dt.month, s) -- mmm
s.append_character (' ') -- SPace
s.append_character (' ') -- SPace
s.append_integer (dt.day) -- d
s.append_character (' ') -- SPace
append_2_digits_time_to (dt.time, s) -- hh:mi:ss
s.append_character (' ') -- SPace
s.append_integer (dt.year) -- yyyy
end
feature -- Status report
debug_output: STRING
do
if attached internal_rfc1123_string as st then
Result := st.string
else
create Result.make (32)
append_date_time_to_rfc1123_string (date_time, Result)
end
end
feature {NONE} -- Implementation
append_2_digits_integer_to (i: INTEGER; s: STRING)
require
is_not_negative: i >= 0
do
if i <= 9 then
s.append_character ('0')
end
s.append_integer (i)
end
append_2_digits_time_to (t: TIME; s: STRING)
do
append_2_digits_integer_to (t.hour, s) -- hh
s.append_character (':') -- :
append_2_digits_integer_to (t.minute, s) -- mi
s.append_character (':') -- :
append_2_digits_integer_to (t.second, s) -- ss
end
append_day_ddd_to (d: INTEGER; s: STRING)
require
1 <= d and d <= 7
do
inspect d
when 1 then s.append ("Sun")
when 2 then s.append ("Mon")
when 3 then s.append ("Tue")
when 4 then s.append ("Wed")
when 5 then s.append ("Thu")
when 6 then s.append ("Fri")
when 7 then s.append ("Sat")
else
-- Error
end
end
append_day_name_to (d: INTEGER; s: STRING)
require
1 <= d and d <= 7
do
inspect d
when 1 then s.append ("Sunday")
when 2 then s.append ("Monday")
when 3 then s.append ("Tuesday")
when 4 then s.append ("Wednesday")
when 5 then s.append ("Thursday")
when 6 then s.append ("Friday")
when 7 then s.append ("Saturday")
else
-- Error
end
end
append_month_mmm_to (m: INTEGER; s: STRING)
require
1 <= m and m <= 12
do
inspect m
when 1 then s.append ("Jan")
when 2 then s.append ("Feb")
when 3 then s.append ("Mar")
when 4 then s.append ("Apr")
when 5 then s.append ("May")
when 6 then s.append ("Jun")
when 7 then s.append ("Jul")
when 8 then s.append ("Aou")
when 9 then s.append ("Sep")
when 10 then s.append ("Oct")
when 11 then s.append ("Nov")
when 12 then s.append ("Dec")
else
-- Error
end
end
feature {NONE} -- Implementation
string_to_date_time (s: READABLE_STRING_8): detachable DATE_TIME
-- String representation of `dt' using the RFC 1123
-- HTTP-date = rfc1123-date | rfc850-date | asctime-date
-- rfc1123-date = wkday "," SP date1 SP time SP "GMT"
-- rfc850-date = weekday "," SP date2 SP time SP "GMT"
-- asctime-date = wkday SP date3 SP time SP 4DIGIT
-- date1 = 2DIGIT SP month SP 4DIGIT
-- ; day month year (e.g., 02 Jun 1982)
-- date2 = 2DIGIT "-" month "-" 2DIGIT
-- ; day-month-year (e.g., 02-Jun-82)
-- date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
-- ; month day (e.g., Jun 2)
-- time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
-- ; 00:00:00 - 23:59:59
-- wkday = "Mon" | "Tue" | "Wed"
-- | "Thu" | "Fri" | "Sat" | "Sun"
-- weekday = "Monday" | "Tuesday" | "Wednesday"
-- | "Thursday" | "Friday" | "Saturday" | "Sunday"
-- month = "Jan" | "Feb" | "Mar" | "Apr"
-- | "May" | "Jun" | "Jul" | "Aug"
-- | "Sep" | "Oct" | "Nov" | "Dec"
--| Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
--| Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
--| Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
note
EIS: "name=RFC2616", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html"
local
t: STRING_8
l_ddd, l_mmm: detachable STRING_8
l_dd, l_yyyy, l_hh, l_mi, l_ss, l_ff2: INTEGER
l_mo: INTEGER
l_gmt_offset: INTEGER -- minutes
i, n: INTEGER
err: BOOLEAN
do
i := 1
n := s.count
create t.make (4)
-- Skip blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| ddd
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count >= 3 then -- Accept full day string
l_ddd := t.as_lower
else
err := True
end
--| blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| ,[0]dd
if not err and i <= n and s[i] = ',' then
i := i + 1
from until i > n or else not s[i].is_space loop i := i + 1 end
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.is_integer end
l_dd := t.to_integer
else
err := True
end
else
err := True
end
--| blanks or '-'
if s[i] = '-' then
i := i + 1
else
from until i > n or else not s[i].is_space loop i := i + 1 end
end
--| mmm
if not err then
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count >= 3 then
l_mmm := t.as_upper
if l_mmm.count > 3 then
-- Tolerant to full month name ..
l_mmm.keep_head (3)
end
if l_mmm.same_string ("JAN") then l_mo := 01
elseif l_mmm.same_string ("FEB") then l_mo := 02
elseif l_mmm.same_string ("MAR") then l_mo := 03
elseif l_mmm.same_string ("APR") then l_mo := 04
elseif l_mmm.same_string ("MAY") then l_mo := 05
elseif l_mmm.same_string ("JUN") then l_mo := 06
elseif l_mmm.same_string ("JUL") then l_mo := 07
elseif l_mmm.same_string ("AOU") then l_mo := 08
elseif l_mmm.same_string ("SEP") then l_mo := 09
elseif l_mmm.same_string ("OCT") then l_mo := 10
elseif l_mmm.same_string ("NOV") then l_mo := 11
elseif l_mmm.same_string ("DEC") then l_mo := 12
else err := True
end
else
err := True
end
end
--| blanks or '-'
if s[i] = '-' then
i := i + 1
else
from until i > n or else not s[i].is_space loop i := i + 1 end
end
--| yyyy
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.count = 4 or t.count = 2 and t.is_integer end
l_yyyy := t.to_integer
if t.count = 2 then
-- RFC 850
l_yyyy := 1900 + l_yyyy
end
else
err := True
end
end
--| blank
from until i > n or else not s[i].is_space loop i := i + 1 end
--| [0]hh:
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 and s[i] = ':' then
check t.count = 2 and t.is_integer end
l_hh := t.to_integer
i := i + 1
else
err := True
end
end
--| [0]mi:
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 and s[i] = ':' then
check t.count = 2 and t.is_integer end
l_mi := t.to_integer
i := i + 1
else
err := True
end
end
--| [0]ss
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.count = 2 and t.is_integer end
l_ss := t.to_integer
else
err := True
end
end
--| .ff2
if not err and s[i] = '.' then
--| .ff2
i := i + 1
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.is_integer end
l_ff2 := t.to_integer
else
err := True
end
end
if not err then
from until i > n or else not s[i].is_space loop i := i + 1 end
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i].as_upper)
i := i + 1
end
if t.same_string ("GMT") or t.same_string ("UTC") then
from until i > n or else not s[i].is_space loop i := i + 1 end
if i <= n then
t.wipe_out
if s[i] = '+' then
t.extend (s[i])
elseif s[i] = '-' then
t.extend (s[i])
else
err := True
end
if not err then
i := i + 1
from until i > n or else not s[i].is_space loop i := i + 1 end
from until i > n or else not s[i].is_digit loop
t.extend (s[i].as_upper)
i := i + 1
end
l_gmt_offset := t.to_integer * 60
if i <= n and s[i] = ':' then
i := i + 1
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i].as_upper)
i := i + 1
end
l_gmt_offset := l_gmt_offset + l_gmt_offset.sign * t.to_integer
end
end
end
else
err := True
end
end
if not err then
check
valid_yyyy: 0 < l_yyyy
valid_dd: 0 < l_dd and l_dd <= 31
valid_mo: 0 < l_mo and l_mo <= 12
valid_hh: 0 <= l_hh and l_hh <= 23
valid_mi: 0 <= l_mi and l_mi <= 59
valid_ss: 0 <= l_ss and l_ss <= 59
end
create Result.make (l_yyyy, l_mo, l_dd, l_hh, l_mi, l_ss)
if l_gmt_offset /= 0 then
Result.minute_add (- l_gmt_offset)
end
else
-- Void is better than wrong date.
end
end
ansi_c_string_to_date_time (s: READABLE_STRING_8): detachable DATE_TIME
-- String representation of `dt' using the RFC 1123
-- asctime-date = wkday SP date3 SP time SP 4DIGIT
-- date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
-- ; month day (e.g., Jun 2)
-- time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
-- ; 00:00:00 - 23:59:59
-- wkday = "Mon" | "Tue" | "Wed"
-- | "Thu" | "Fri" | "Sat" | "Sun"
-- month = "Jan" | "Feb" | "Mar" | "Apr"
-- | "May" | "Jun" | "Jul" | "Aug"
-- | "Sep" | "Oct" | "Nov" | "Dec"
--| Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
note
EIS: "name=RFC2616", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html"
local
t: STRING_8
l_ddd, l_mmm: detachable STRING_8
l_dd, l_yyyy, l_hh, l_mi, l_ss, l_ff2: INTEGER
l_mo: INTEGER
l_gmt_offset: INTEGER -- minutes
i, n: INTEGER
err: BOOLEAN
do
i := 1
n := s.count
create t.make (4)
-- Skip blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| ddd
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count >= 3 then -- Accept full day string
l_ddd := t.as_lower
else
err := True
end
--| blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| mmm
if not err then
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count >= 3 then
l_mmm := t.as_upper
if l_mmm.count > 3 then
-- Tolerant to full month name ..
l_mmm.keep_head (3)
end
if l_mmm.same_string ("JAN") then l_mo := 01
elseif l_mmm.same_string ("FEB") then l_mo := 02
elseif l_mmm.same_string ("MAR") then l_mo := 03
elseif l_mmm.same_string ("APR") then l_mo := 04
elseif l_mmm.same_string ("MAY") then l_mo := 05
elseif l_mmm.same_string ("JUN") then l_mo := 06
elseif l_mmm.same_string ("JUL") then l_mo := 07
elseif l_mmm.same_string ("AOU") then l_mo := 08
elseif l_mmm.same_string ("SEP") then l_mo := 09
elseif l_mmm.same_string ("OCT") then l_mo := 10
elseif l_mmm.same_string ("NOV") then l_mo := 11
elseif l_mmm.same_string ("DEC") then l_mo := 12
else err := True
end
else
err := True
end
end
--| blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| dd
if not err and i <= n then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.is_integer end
l_dd := t.to_integer
else
err := True
end
else
err := True
end
--| blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| [0]hh:
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 and s[i] = ':' then
check t.count = 2 and t.is_integer end
l_hh := t.to_integer
i := i + 1
else
err := True
end
end
--| [0]mi:
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 and s[i] = ':' then
check t.count = 2 and t.is_integer end
l_mi := t.to_integer
i := i + 1
else
err := True
end
end
--| [0]ss
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.count = 2 and t.is_integer end
l_ss := t.to_integer
else
err := True
end
end
--| .ff2
if not err and s[i] = '.' then
--| .ff2
i := i + 1
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if i <= n and t.count > 0 then
check t.is_integer end
l_ff2 := t.to_integer
else
err := True
end
end
--| blanks
from until i > n or else not s[i].is_space loop i := i + 1 end
--| yyyy
if not err then
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i])
i := i + 1
end
if t.count > 0 then
check t.count = 4 or t.count = 2 and t.is_integer end
l_yyyy := t.to_integer
if t.count = 2 then
-- RFC 850
l_yyyy := 1900 + l_yyyy
end
else
err := True
end
end
--| blank
from until i > n or else not s[i].is_space loop i := i + 1 end
if i <= n and not err then
from until i > n or else not s[i].is_space loop i := i + 1 end
t.wipe_out
from until i > n or else not s[i].is_alpha loop
t.extend (s[i].as_upper)
i := i + 1
end
if t.same_string ("GMT") or t.same_string ("UTC") then
from until i > n or else not s[i].is_space loop i := i + 1 end
if i <= n then
t.wipe_out
if s[i] = '+' then
t.extend (s[i])
elseif s[i] = '-' then
t.extend (s[i])
else
err := True
end
if not err then
i := i + 1
from until i > n or else not s[i].is_space loop i := i + 1 end
from until i > n or else not s[i].is_digit loop
t.extend (s[i].as_upper)
i := i + 1
end
l_gmt_offset := t.to_integer * 60
if i <= n and s[i] = ':' then
i := i + 1
t.wipe_out
from until i > n or else not s[i].is_digit loop
t.extend (s[i].as_upper)
i := i + 1
end
l_gmt_offset := l_gmt_offset + l_gmt_offset.sign * t.to_integer
end
end
end
else
err := True
end
end
if not err then
check
valid_yyyy: 0 < l_yyyy
valid_dd: 0 < l_dd and l_dd <= 31
valid_mo: 0 < l_mo and l_mo <= 12
valid_hh: 0 <= l_hh and l_hh <= 23
valid_mi: 0 <= l_mi and l_mi <= 59
valid_ss: 0 <= l_ss and l_ss <= 59
end
create Result.make (l_yyyy, l_mo, l_dd, l_hh, l_mi, l_ss)
if l_gmt_offset /= 0 then
Result.minute_add (- l_gmt_offset)
end
else
-- Void is better than wrong date.
end
end
invariant
note
copyright: "2011-2013, Jocelyn Fiat, 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

View File

@@ -69,23 +69,9 @@ feature {NONE} -- Initialization
make_from_raw_header_data (h: READABLE_STRING_8)
-- Create Current from raw header data
local
line : detachable STRING
lines: LIST [READABLE_STRING_8]
do
lines := h.split ('%N')
make_with_count (lines.count)
across
lines as c
loop
line := c.item
if not line.is_empty then
if line [line.count] = '%R' then
line.remove_tail (1)
end
add_header (line)
end
end
make
append_raw_header_data (h)
end
feature -- Recycle
@@ -111,23 +97,19 @@ feature -- Access
end
headers: ARRAYED_LIST [READABLE_STRING_8]
-- Header's lines
-- Header's lines.
string: STRING_8
-- String representation of the headers
-- String representation of the header entries.
local
l_headers: like headers
n: like count
do
l_headers := headers
if not l_headers.is_empty then
create Result.make (l_headers.count * 32)
across
l_headers as c
loop
append_line_to (c.item, Result)
end
else
n := count
if n = 0 then
create Result.make_empty
else
create Result.make (n * 32)
append_string_to (Result)
end
ensure
result_has_ending_cr_lf: Result.count >= 2 implies Result.substring (Result.count - 1, Result.count).same_string ("%R%N")
@@ -135,6 +117,7 @@ feature -- Access
end
to_name_value_iterable: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]
-- Iterable representation of the header entries.
local
res: ARRAYED_LIST [TUPLE [READABLE_STRING_8, READABLE_STRING_8]]
do
@@ -149,15 +132,53 @@ feature -- Access
Result := res
end
feature -- Conversion
append_string_to (a_result: STRING_8)
-- Append current as string representation to `a_result'
local
l_headers: like headers
do
l_headers := headers
if not l_headers.is_empty then
across
l_headers as c
loop
append_line_to (c.item, a_result)
end
end
end
feature -- Access
new_cursor: INDEXABLE_ITERATION_CURSOR [READABLE_STRING_8]
-- Fresh cursor associated with current structure
-- Fresh cursor associated with current structure.
do
Result := headers.new_cursor
end
feature -- Header: filling
feature -- Header: adding
append_raw_header_data (h: READABLE_STRING_8)
-- Append raw header data `h' to Current
local
line : detachable STRING
lines: LIST [READABLE_STRING_8]
do
lines := h.split ('%N')
headers.grow (headers.count + lines.count)
across
lines as c
loop
line := c.item
if not line.is_empty then
if line [line.count] = '%R' then
line.remove_tail (1)
end
add_header (line)
end
end
end
append_array (a_headers: ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Append array of key,value headers
@@ -166,7 +187,7 @@ feature -- Header: filling
across
a_headers as c
loop
put_header_key_value (c.item.key, c.item.value)
add_header_key_value (c.item.key, c.item.value)
end
end
@@ -181,6 +202,54 @@ feature -- Header: filling
end
end
feature -- Header: merging
put_raw_header_data (h: READABLE_STRING_8)
-- Append raw header data `h' to Current
-- Overwrite existing header with same name
local
line : detachable STRING
lines: LIST [READABLE_STRING_8]
do
lines := h.split ('%N')
headers.grow (headers.count + lines.count)
across
lines as c
loop
line := c.item
if not line.is_empty then
if line [line.count] = '%R' then
line.remove_tail (1)
end
put_header (line)
end
end
end
put_array (a_headers: ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Append array of key,value headers
-- Overwrite existing header with same name
do
headers.grow (headers.count + a_headers.count)
across
a_headers as c
loop
put_header_key_value (c.item.key, c.item.value)
end
end
put_header_object (h: HTTP_HEADER)
-- Append headers from `h'
-- Overwrite existing header with same name
do
headers.grow (headers.count + h.headers.count)
across
h.headers as c
loop
put_header (c.item.string)
end
end
feature -- Header change: general
add_header (h: READABLE_STRING_8)
@@ -203,14 +272,52 @@ feature -- Header change: general
add_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key
local
s: STRING_8
do
add_header (k + colon_space + v)
create s.make (k.count + 2 + v.count)
s.append (k)
s.append (colon_space)
s.append (v)
add_header (s)
end
put_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key
local
s: STRING_8
do
put_header (k + colon_space + v)
create s.make (k.count + 2 + v.count)
s.append (k)
s.append (colon_space)
s.append (v)
put_header (s)
end
put_header_key_values (k: READABLE_STRING_8; a_values: ITERABLE [READABLE_STRING_8]; a_separator: detachable READABLE_STRING_8)
-- Add header `k: a_values', or replace existing header of same header values/key.
-- Use `comma_space' as default separator if `a_separator' is Void or empty.
local
s: STRING_8
l_separator: READABLE_STRING_8
do
if a_separator /= Void and then not a_separator.is_empty then
l_separator := a_separator
else
l_separator := comma_space
end
create s.make_empty
across
a_values as c
loop
if not s.is_empty then
s.append_string (l_separator)
end
s.append (c.item)
end
if not s.is_empty then
put_header_key_value (k, s)
end
end
put_header_key_methods (k: READABLE_STRING_8; a_methods: ITERABLE [READABLE_STRING_8])
@@ -447,7 +554,7 @@ feature -- Method related
put_allow (a_methods: ITERABLE [READABLE_STRING_8])
-- If `a_methods' is not empty, put `Allow' header with list `a_methods' of methods
do
put_header_key_methods ({HTTP_HEADER_NAMES}.header_allow, a_methods)
put_header_key_values ({HTTP_HEADER_NAMES}.header_allow, a_methods, Void)
end
feature -- Date
@@ -552,13 +659,16 @@ feature -- Cookie
if
domain /= Void and then not domain.same_string ("localhost")
then
s.append ("; Domain=" + domain)
s.append ("; Domain=")
s.append (domain)
end
if path /= Void then
s.append ("; Path=" + path)
s.append ("; Path=")
s.append (path)
end
if expiration /= Void then
s.append ("; Expires=" + expiration)
s.append ("; Expires=")
s.append (expiration)
end
if secure then
s.append ("; Secure")
@@ -756,8 +866,11 @@ feature {NONE} -- Implementation
date_to_rfc1123_http_date_format (dt: DATE_TIME): STRING_8
-- String representation of `dt' using the RFC 1123
local
d: HTTP_DATE
do
Result := dt.formatted_out ("ddd, [0]dd mmm yyyy [0]hh:[0]mi:[0]ss") + " GMT"
create d.make_from_date_time (dt)
Result := d.string
end
feature {NONE} -- Constants
@@ -765,8 +878,20 @@ feature {NONE} -- Constants
str_binary: STRING = "binary"
str_chunked: STRING = "chunked"
colon_space: STRING = ": "
semi_colon_space: STRING = "; "
colon_space: IMMUTABLE_STRING_8
once
create Result.make_from_string (": ")
end
semi_colon_space: IMMUTABLE_STRING_8
once
create Result.make_from_string ("; ")
end
comma_space: IMMUTABLE_STRING_8
once
create Result.make_from_string (", ")
end
note
copyright: "2011-2013, Jocelyn Fiat, Eiffel Software and others"

View File

@@ -0,0 +1,15 @@
class
AUTOTEST
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
end
end

View File

@@ -0,0 +1,77 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
HTTP_DATE_TEST_SET
inherit
EQA_TEST_SET
feature -- Test routines
test_http_date
-- New test routine
local
s: STRING
d: HTTP_DATE
do
s := "Sun, 06 Nov 1994 08:49:37 GMT"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string (s))
create d.make_from_timestamp (d.timestamp)
assert ("RFC 1123", not d.has_error and then d.string.same_string (s))
s := "Sunday, 06-Nov-94 08:49:37 GMT"
create d.make_from_string (s)
assert ("RFC 850", not d.has_error and then d.rfc850_string.same_string (s))
create d.make_from_timestamp (d.timestamp)
assert ("RFC 850", not d.has_error and then d.rfc850_string.same_string (s))
s := "Sun, 06 Nov 1994 08:49:37 GMT"
create d.make_from_string (s)
assert ("ANSI C format", not d.has_error and then d.ansi_c_string.same_string ("Sun Nov 6 08:49:37 1994"))
s := "Sun Nov 6 08:49:37 1994"
create d.make_from_string (s)
assert ("ANSI C format", not d.has_error and then d.ansi_c_string.same_string (s))
-- Tolerance ...
s := "Sun, 06 November 1994 09:49:37 GMT+1"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Sun, 06 Nov 1994 08:49:37 GMT"))
s := "Sun, 06 Nov 1994 09:49:37 GMT+1"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Sun, 06 Nov 1994 08:49:37 GMT"))
s := "Sun, 06 Nov 1994 07:49:37 GMT-1"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Sun, 06 Nov 1994 08:49:37 GMT"))
s := "Sun, 06 Nov 1994 10:19:37 GMT+1:30"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Sun, 06 Nov 1994 08:49:37 GMT"))
s := "Sun, 06 Nov 1994 07:19:37 GMT-1:30"
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Sun, 06 Nov 1994 08:49:37 GMT"))
s := "Thu, 31 Jan 2013 15:35:00 GMT+5:45" -- NPT
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Thu, 31 Jan 2013 09:50:00 GMT"))
s := "Thu, 31 Jan 2013 05:20:00 GMT-4:30" -- VET
create d.make_from_string (s)
assert ("RFC 1123", not d.has_error and then d.string.same_string ("Thu, 31 Jan 2013 09:50:00 GMT"))
end
end

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="tests" uuid="0582ACC2-11D8-4FE5-888D-61837BA8F43E">
<target name="tests">
<root class="AUTOTEST" feature="make"/>
<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="standard">
</option>
<setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="http" location="..\http-safe.ecf" readonly="false"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<tests name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,18 @@
<?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="tests" uuid="0582ACC2-11D8-4FE5-888D-61837BA8F43E">
<target name="tests">
<root class="ANY" feature="default_create"/>
<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>
<setting name="concurrency" value="none"/>
<library name="http" location="..\http.ecf"/>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="testing" location="$ISE_LIBRARY/library/testing/testing.ecf"/>
<tests name="src" location="." recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,5 @@
OpenID
http://en.wikipedia.org/wiki/Openid
Anyone wanting to contribute is welcome

View File

@@ -0,0 +1,5 @@
OpenID consumer
http://en.wikipedia.org/wiki/Openid
Anyone wanting to contribute is welcome

View File

@@ -0,0 +1,149 @@
note
description : "OPENID demo application root class"
date : "$Date$"
revision : "$Revision$"
class
APPLICATION
inherit
WSF_URI_TEMPLATE_ROUTED_SERVICE
WSF_SERVICE
create
make_and_launch
feature {NONE} -- Initialization
make_and_launch
local
launcher: WSF_NINO_SERVICE_LAUNCHER
opts: WSF_SERVICE_LAUNCHER_OPTIONS
do
initialize_router
create opts.make
opts.set_verbose (True)
opts.set_option ("port", 0)
create launcher.make (Current, opts)
launcher.on_launched_actions.extend (agent on_launched)
launcher.launch
end
on_launched (conn: WGI_CONNECTOR)
local
e: EXECUTION_ENVIRONMENT
do
if attached {WGI_NINO_CONNECTOR} conn as nino then
create e
if attached e.get ("COMSPEC") as l_comspec then
e.launch (l_comspec + " /C start " + "http://localhost:" + nino.port.out + "/")
else
e.launch ("http://localhost:" + nino.port.out + "/")
end
end
end
setup_router
do
map_uri_template_agent ("/", agent handle_root)
map_uri_template_agent ("/openid", agent handle_openid)
end
handle_root (req: WSF_REQUEST; res: WSF_RESPONSE)
local
m: WSF_HTML_PAGE_RESPONSE
s: STRING
do
create m.make
m.set_title ("EWF::OpenID demo")
create s.make_empty
s.append ("<form action=%"" + req.script_url ("/openid") + "%" method=%"POST%">%N")
s.append ("<strong>OpenID identifier</strong> <input type='text' name='openid_identifier' value='' size='60'/>")
s.append ("<input type='submit' name='op' value='sign with OpenID' />")
s.append ("</form>%N")
s.append ("<form action=%"" + req.script_url ("/openid") + "%" method=%"POST%">%N")
s.append ("<strong>OpenID identifier</strong> <input type='text' name='openid_identifier' value='https://www.google.com/accounts/o8/id' size='60'/>")
s.append ("<input type='submit' name='op' value='sign with Google' />")
s.append ("</form>%N")
m.set_body (s)
res.send (m)
end
handle_openid (req: WSF_REQUEST; res: WSF_RESPONSE)
local
m: WSF_HTML_PAGE_RESPONSE
redir: WSF_HTML_DELAYED_REDIRECTION_RESPONSE
s: STRING
o: OPENID_CONSUMER
v: OPENID_CONSUMER_VALIDATION
do
if attached req.string_item ("openid.mode") as l_openid_mode then
create m.make
m.set_title ("EWF::OpenID demo")
create s.make_empty
if l_openid_mode.same_string ("id_res") then
o := new_openid_consumer (req)
create v.make_from_items (o, req.items_as_string_items)
v.validate
if v.is_valid then
s.append ("<div>User authenticated</div>")
s.append ("<ul>Request items")
across
req.items as c
loop
s.append ("<li>" + c.item.url_encoded_name + "=" + c.item.string_representation + "</li>")
end
s.append ("</ul>")
s.append ("<ul>Attributes")
across
v.attributes as c
loop
s.append ("<li>" + c.key + "=" + c.item + "</li>")
end
s.append ("</ul>")
else
s.append ("<div>User authentication failed!!!</div>")
end
else
s.append ("<div>Unexpected OpenID.mode=" + l_openid_mode + "</div>")
end
m.set_body (s)
res.send (m)
elseif attached req.string_item ("openid_identifier") as l_id then
create s.make_empty
o := new_openid_consumer (req)
s.append ("Testing " + l_id + "<br>%N")
s.append ("Return-to" + o.return_url + "<br>")
if attached o.auth_url (l_id) as l_auth_url then
s.append ("<a href=%""+ l_auth_url + "%">Click to sign with " + l_id + "</a><br>")
create redir.make (l_auth_url, 1)
s.append ("Automatically follow link in " + redir.delay.out + " second(s)<br>")
redir.set_title ("EWF::OpenID demo")
redir.set_body (s)
res.send (redir)
else
create m.make
m.set_title ("EWF::OpenID demo")
m.set_body (s)
res.send (m)
end
else
res.redirect_now ("/")
end
end
new_openid_consumer (req: WSF_REQUEST): OPENID_CONSUMER
do
create Result.make (req.absolute_script_url ("/openid"))
Result.ask_email (True)
Result.ask_all_info (False)
-- Result.ask_nickname (False)
-- Result.ask_fullname (False)
-- Result.ask_country (True)
end
end

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="demo" uuid="DC4D6549-D5F4-4E1A-959A-6BD536737A21" library_target="demo">
<target name="demo">
<root class="APPLICATION" feature="make_and_launch"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="../../../../server/ewsgi/ewsgi-safe.ecf" readonly="false"/>
<library name="ewsgi_nino_connector" location="../../../../server/ewsgi/connectors/nino/nino-safe.ecf" readonly="false"/>
<library name="http" location="../../../../network/protocol/http/http-safe.ecf"/>
<library name="openid" location="..\openid-safe.ecf" readonly="false"/>
<library name="wsf" location="../../../../server/wsf/wsf-safe.ecf" readonly="false"/>
<library name="wsf_nino_connector" location="../../../../server/wsf/connector/nino-safe.ecf" readonly="false"/>
<cluster name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,20 @@
<?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="openid" uuid="FCDB4F81-31EC-462B-9183-D506E6798C0B" library_target="openid">
<target name="openid">
<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="standard">
</option>
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL-safe.ecf" readonly="false"/>
<library name="uri" location="../../../../contrib/ise_library/text/uri/uri-safe.ecf" readonly="false"/>
<library name="xml_parser" location="$ISE_LIBRARY\library\text\parser\xml\parser\xml_parser-safe.ecf"/>
<library name="xml_tree" location="$ISE_LIBRARY\library\text\parser\xml\tree\xml_tree-safe.ecf" readonly="false"/>
<library name="http_client" location="../../../network/http_client/http_client-safe.ecf"/>
<cluster name="src" location="src" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,21 @@
<?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="openid" uuid="FCDB4F81-31EC-462B-9183-D506E6798C0B" library_target="openid">
<target name="openid">
<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="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL.ecf" readonly="false"/>
<library name="uri" location="../../../../contrib/ise_library/text/uri/uri.ecf" readonly="false"/>
<library name="xml_parser" location="$ISE_LIBRARY\library\text\parser\xml\parser\xml_parser.ecf"/>
<library name="xml_tree" location="$ISE_LIBRARY\library\text\parser\xml\tree\xml_tree.ecf" readonly="false"/>
<library name="http_client" location="../../../network/http_client/http_client.ecf"/>
<cluster name="src" location="src" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,520 @@
note
description: "[
Light implementation of {OPENID} consumer.
Sign-on with OpenID is a two step process:
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
OPENID_CONSUMER
create
make
feature {NONE} -- Initialization
make (a_server: READABLE_STRING_8)
do
trusted_root := a_server
return_url := a_server
create required_info.make (0)
create optional_info.make (0)
end
feature -- Access
trusted_root: READABLE_STRING_8
return_url: READABLE_STRING_8
required_info: ARRAYED_LIST [READABLE_STRING_8]
optional_info: ARRAYED_LIST [READABLE_STRING_8]
error: detachable READABLE_STRING_8
has_error: BOOLEAN
do
Result := error /= Void
end
feature -- Change
ask_all_info (is_required: BOOLEAN)
do
across
ax_to_sreg_map as c
loop
ask_info (c.key.to_string_32, is_required)
end
end
ask_required_info (s: READABLE_STRING_8)
do
required_info.force (s)
end
ask_optional_info (s: READABLE_STRING_8)
do
optional_info.force (s)
end
ask_info (s: READABLE_STRING_8; is_required: BOOLEAN)
do
if is_required then
ask_required_info (s)
else
ask_optional_info (s)
end
end
ask_nickname (is_required: BOOLEAN)
do
ask_info ("namePerson/friendly", is_required)
end
ask_email (is_required: BOOLEAN)
do
ask_info ("contact/email", is_required)
end
ask_fullname (is_required: BOOLEAN)
do
ask_info ("namePerson", is_required)
end
ask_birthdate (is_required: BOOLEAN)
do
ask_info ("birthDate", is_required)
end
ask_gender (is_required: BOOLEAN)
do
ask_info ("person/gender", is_required)
end
ask_postcode (is_required: BOOLEAN)
do
ask_info ("contact/postalCode/home", is_required)
end
ask_country (is_required: BOOLEAN)
do
ask_info ("contact/country/home", is_required)
end
ask_language (is_required: BOOLEAN)
do
ask_info ("pref/language", is_required)
end
ask_timezone (is_required: BOOLEAN)
do
ask_info ("pref/timezone", is_required)
end
feature -- Query
auth_url (a_identity: READABLE_STRING_8): detachable READABLE_STRING_8
do
error := Void
if attached discovering_info (a_identity) as d_info then
if d_info.version = 2 then
Result := auth_url_v2 (a_identity, d_info)
else
Result := auth_url_v1 (a_identity, d_info) -- FIXME for claimed_id
end
end
end
feature {OPENID_CONSUMER_VALIDATION} -- Implementation
discovering_info (id: READABLE_STRING_8): detachable OPENID_DISCOVER
local
sess: HTTP_CLIENT_SESSION
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
xrds_location: detachable READABLE_STRING_8
xml: XML_LITE_PARSER
tree: XML_CALLBACKS_DOCUMENT
xelt: detachable XML_ELEMENT
s: READABLE_STRING_32
r_uri: detachable READABLE_STRING_8
r_err: BOOLEAN
r_delegate: detachable READABLE_STRING_8
r_sreg_supported, r_ax_supported, r_identifier_select: BOOLEAN
r_version: INTEGER
l_xrds_content: detachable READABLE_STRING_8
do
sess := new_session (id)
if attached sess.head ("", ctx) as rep then
if rep.error_occurred then
report_error ("Unable get answer from openid provider at " + rep.url)
else
if
attached rep.header ("Content-Type") as l_content_type and then
l_content_type.has_substring ("application/xrds+xml") and then
attached sess.get ("", ctx) as l_getres
then
l_xrds_content := l_getres.body
elseif attached rep.header ("X-XRDS-Location") as loc then
xrds_location := loc
else
report_error ("Failed (probably %""+ id +"%" is an invalid openid identifier).")
end
end
end
if l_xrds_content = Void and xrds_location /= Void then
sess := new_session (xrds_location)
if attached sess.get ("", ctx) as rep then
if rep.error_occurred then
r_err := True
report_error ("Can not get " + rep.url)
elseif attached rep.body as l_content then
l_xrds_content := l_content
else
r_err := True
report_error ("No content: " + rep.url)
end
end
end
if l_xrds_content = Void then
r_err := True
report_error ("Unable to get the XRDS message.")
else
create xml.make
create tree.make_null
xml.set_callbacks (tree)
xml.parse_from_string (l_xrds_content)
if attached tree.document as xrds then
xelt := Void
xelt := xrds.elements.first
xelt := xelt.elements.first
if attached xelt as l_xrd then
if attached l_xrd.elements_by_name ("Service") as l_services then
across
l_services as c
until
r_uri /= Void
loop
if attached c.item.elements_by_name ("Type") as l_types then
across
l_types as t
loop
s := xml_content (t.item)
if s.same_string ("http://openid.net/sreg/1.0") then
r_sreg_supported := True
elseif s.same_string ("http://openid.net/extensions/sreg/1.1") then
r_sreg_supported := True
elseif s.same_string ("http://openid.net/srv/ax/1.0") then
r_ax_supported := True
elseif s.same_string ("http://specs.openid.net/auth/2.0/signon") then
r_version := 2
elseif s.same_string ("http://specs.openid.net/auth/2.0/server") then
r_version := 2
r_identifier_select := True
elseif s.same_string ("http://openid.net/signon/1.1") then
r_version := 1
end
end
end
if attached c.item.element_by_name ("URI") as l_uri then
r_uri := xml_content (l_uri)
end
if r_version = 1 then
if attached c.item.element_by_name ("openid:Delegate") as l_id then
r_delegate := xml_content (l_id)
end
if attached c.item.element_by_name ("LocalID") as l_id then
r_delegate := xml_content (l_id)
end
else
if attached c.item.element_by_name ("CanonicalID") as l_id then
r_delegate := xml_content (l_id)
end
if attached c.item.element_by_name ("LocalID") as l_id then
r_delegate := xml_content (l_id)
end
end
end
end
end
end
end
if r_uri /= Void then
create Result.make (r_uri, r_version)
if r_delegate = Void then
r_delegate := id
end
Result.delegate := r_delegate
Result.ax_supported := r_ax_supported
Result.sreg_supported := r_sreg_supported
Result.identifier_select := r_identifier_select
Result.has_error := r_err
end
end
feature {NONE} -- Implementation
auth_url_v1 (a_id: READABLE_STRING_8; a_info: OPENID_DISCOVER): READABLE_STRING_8
local
u: URI
ret: URI
do
create u.make_from_string (a_info.server_uri)
create ret.make_from_string (return_url)
if
attached a_info.delegate as l_claimed_id and then
not a_id.same_string (l_claimed_id)
then
ret.add_query_parameter ("openid.claimed_id", l_claimed_id)
end
u.add_query_parameter ("openid.return_to", ret.string)
u.add_query_parameter ("openid.mode", "checkid_setup") -- or "checkid_immediate"
u.add_query_parameter ("openid.identity", a_id)
u.add_query_parameter ("openid.trust_root", trusted_root)
if a_info.sreg_supported then
add_sreg_parameters_to (u)
end
Result := u.string
end
auth_url_v2 (a_id: READABLE_STRING_8; a_info: OPENID_DISCOVER): READABLE_STRING_8
local
u: URI
do
create u.make_from_string (a_info.server_uri)
u.add_query_parameter ("openid.ns", "http://specs.openid.net/auth/2.0")
u.add_query_parameter ("openid.mode", "checkid_setup") -- or "checkid_immediate"
u.add_query_parameter ("openid.return_to", return_url)
u.add_query_parameter ("openid.realm", trusted_root)
if a_info.ax_supported then
add_ax_parameters_to (u)
end
if a_info.sreg_supported then
add_sreg_parameters_to (u)
end
if a_info.identifier_select then
u.add_query_parameter ("openid.identity", "http://specs.openid.net/auth/2.0/identifier_select")
u.add_query_parameter ("openid.claimed_id", "http://specs.openid.net/auth/2.0/identifier_select")
else
u.add_query_parameter ("openid.identity", a_id)
u.add_query_parameter ("openid.claimed_id", a_id) -- Fixme
end
Result := u.string
end
add_ax_parameters_to (a_uri: URI)
local
lst: ARRAYED_LIST [READABLE_STRING_8]
l_aliases: HASH_TABLE [READABLE_STRING_8, STRING_8]
l_counts: HASH_TABLE [INTEGER, STRING_8]
l_alias: READABLE_STRING_8
s: STRING
do
create lst.make (required_info.count + optional_info.count)
lst.append (required_info)
lst.append (optional_info)
if lst.count > 0 then
a_uri.add_query_parameter ("openid.ns.ax", "http://openid.net/srv/ax/1.0")
a_uri.add_query_parameter ("openid.ax.mode", "fetch_request");
create l_aliases.make (lst.count)
create l_counts.make (lst.count)
across
lst as c
loop
l_alias := ax_to_alias (c.item)
if l_aliases.has (l_alias) then
if attached l_counts.item (l_alias) as l_count then
l_counts.replace (l_count + 1, l_alias)
else
check has_alias: False end
l_counts.force (1, l_alias)
end
else
l_aliases.force ("http://axschema.org/" + c.item, l_alias)
l_counts.force (1, l_alias)
end
end
across
l_aliases as c
loop
a_uri.add_query_parameter ("openid.ax.type." + c.key, c.item)
end
across
l_counts as c
loop
if c.item > 1 then
a_uri.add_query_parameter ("openid.ax.count." + c.key, c.item.out)
end
end
-- required
create s.make_empty
across
required_info as c
loop
if not s.is_empty then
s.append_character (',')
end
s.append (ax_to_alias (c.item))
end
if not s.is_empty then
a_uri.add_query_parameter ("openid.ax.required", s)
end
-- optional
create s.make_empty
across
optional_info as c
loop
if not s.is_empty then
s.append_character (',')
end
s.append (ax_to_alias (c.item))
end
if not s.is_empty then
a_uri.add_query_parameter ("openid.ax.if_available", s)
end
end
end
ax_to_alias (n: READABLE_STRING_8): STRING_8
do
if attached ax_to_sreg (n) as s then
Result := s
else
Result := n.string
Result.replace_substring_all ("/", "_")
Result.replace_substring_all (".", "_")
end
end
add_sreg_parameters_to (a_uri: URI)
local
s: STRING
do
-- We always use SREG 1.1, even if the server is advertising only support for 1.0.
-- That's because it's fully backwards compatibile with 1.0, and some providers
-- advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com
a_uri.add_query_parameter ("openid.ns.sreg", "http://openid.net/extensions/sreg/1.1")
if not required_info.is_empty then
create s.make_empty
across
required_info as c
loop
if attached ax_to_sreg (c.item) as sreg then
if not s.is_empty then
s.append_character (',')
end
s.append (sreg)
end
end
if not s.is_empty then
a_uri.add_query_parameter ("openid.sreg.required", s)
end
end
if not optional_info.is_empty then
create s.make_empty
across
optional_info as c
loop
if attached ax_to_sreg (c.item) as sreg then
if not s.is_empty then
s.append_character (',')
end
s.append (sreg)
end
end
if not s.is_empty then
a_uri.add_query_parameter ("openid.sreg.optional", s)
end
end
end
ax_to_sreg_map: HASH_TABLE [READABLE_STRING_8, STRING_8]
once
create Result.make (7)
Result.compare_objects
Result.force ("nickname", "namePerson/friendly")
Result.force ("email", "contact/email")
Result.force ("fullname", "namePerson")
Result.force ("dob", "birthDate")
Result.force ("gender", "person/gender")
Result.force ("postcode", "contact/postalCode/home")
Result.force ("country", "contact/country/home")
Result.force ("language", "pref/language")
Result.force ("timezone", "pref/timezone")
-- -- extension
-- Result.force ("firstname", "namePerson/first")
-- Result.force ("lastname", "namePerson/last")
end
ax_to_sreg (n: READABLE_STRING_8): detachable READABLE_STRING_8
do
if attached ax_to_sreg_map.item (n) as v then
Result := v
end
end
sreg_to_ax (n: READABLE_STRING_8): detachable READABLE_STRING_8
do
if ax_to_sreg_map.has_item (n) and then
attached ax_to_sreg_map.found_item as v
then
Result := v
end
end
report_error (m: READABLE_STRING_8)
local
err: like error
do
err := error
if err = Void then
error := m
else
error := err + "%N" + m
end
debug
print (m)
end
ensure
has_error
end
feature -- Helper
xml_content (e: XML_ELEMENT): STRING_8
do
create Result.make_empty
if attached e.contents as lst then
across
lst as c
loop
Result.append (c.item.content)
end
end
end
new_session (a_uri: READABLE_STRING_8): HTTP_CLIENT_SESSION
local
cl: LIBCURL_HTTP_CLIENT
do
create cl.make
Result := cl.new_session (a_uri)
Result.set_is_insecure (True)
Result.set_max_redirects (5)
Result.add_header ("Accept", "application/xrds+xml, */*")
end
end

View File

@@ -0,0 +1,263 @@
note
description: "Summary description for {OPENID_CONSUMER_VALIDATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
OPENID_CONSUMER_VALIDATION
create
make_from_items
feature {NONE} -- Initialization
make_from_items (o: OPENID_CONSUMER; lst: like values)
do
openid := o
values := lst
return_url := o.return_url
create attributes.make (0)
end
values: detachable ITERABLE [TUPLE [name: READABLE_STRING_32; value: detachable READABLE_STRING_32]]
return_url: READABLE_STRING_8
feature -- Access
openid: OPENID_CONSUMER
identity: detachable READABLE_STRING_8
attributes: HASH_TABLE [READABLE_STRING_32, STRING_8]
feature -- Basic operation
validate
-- Is openid identifier validated?
local
l_claimed_id: detachable READABLE_STRING_8
tb: HASH_TABLE [detachable READABLE_STRING_32, STRING_8]
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
ret: URI
sess: HTTP_CLIENT_SESSION
do
is_valid := False
create ret.make_from_string (return_url)
create tb.make (5)
if attached values as q_lst then
if attached item_by_name ("openid.claimed_id", q_lst) as q_claimed_id then
l_claimed_id := q_claimed_id.as_string_8
elseif attached item_by_name ("openid.identity", q_lst) as l_id then
l_claimed_id := l_id
end
identity := l_claimed_id
tb.force (item_by_name ("openid.assoc_handle", q_lst), "openid.assoc_handle")
tb.force (item_by_name ("openid.signed", q_lst), "openid.signed")
tb.force (item_by_name ("openid.sig", q_lst), "openid.sig")
if attached item_by_name ("openid.ns", q_lst) as q_ns then
-- We're dealing with an OpenID 2.0 server, so let's set an ns
-- Even though we should know location of the endpoint,
-- we still need to verify it by discovery, so $server is not set here
tb.force ("http://specs.openid.net/auth/2.0", "openid.ns")
elseif
attached item_by_name ("openid.claimed_id", q_lst) as q_claimed_id
and then (not attached item_by_name ("openid.identity", q_lst) as l_identity
or else not q_claimed_id.same_string (l_identity))
then
-- If it's an OpenID 1 provider, and we've got claimed_id,
-- we have to append it to the returnUrl, like authUrl_v1 does.
ret.add_query_parameter ("openid.claimed_id", q_claimed_id)
return_url := ret.string
else
end
if
attached item_by_name ("openid.return_to", q_lst) as q_return_to and then
not return_url.same_string (q_return_to)
then
-- The return_to url must match the url of current request.
-- I'm assuing that noone will set the returnUrl to something that doesn't make sense.
-- False, FIXME, exception ...
end
if l_claimed_id /= Void then
if
attached openid.discovering_info (l_claimed_id) as d_info and then
not openid.has_error and then not d_info.has_error
then
if attached item_by_name ("openid.signed", q_lst) as lst_signed then
across
lst_signed.split (',') as c
loop
tb.force (item_by_name ("openid." + c.item, q_lst), "openid." + c.item)
end
end
tb.force ("check_authentication", "openid.mode")
create ctx.make
across
tb as c
loop
if attached c.item as l_value then
ctx.add_form_parameter (c.key.to_string_32, l_value)
end
end
sess := openid.new_session (d_info.server_uri)
if attached sess.post ("", ctx, Void) as res then
if res.error_occurred then
elseif attached {STRING} res.body as l_body then
is_valid := l_body.substring_index ("is_valid:true", 1) > 0
if is_valid then
get_attributes (q_lst)
end
end
end
end
end
end
end
get_attributes (lst: like values)
do
attributes.wipe_out
get_sreg_attributes (lst)
get_ax_attributes (lst)
end
get_sreg_attributes (lst: like values)
local
s: READABLE_STRING_32
sreg_keys: ARRAYED_LIST [READABLE_STRING_32]
do
if lst /= Void and then attached item_by_name ("openid.signed", lst) as l_signed then
-- sreg attributes
create sreg_keys.make (5)
across
l_signed.split (',') as c
loop
s := c.item
if s.starts_with ("sreg.") then
sreg_keys.force ("openid." + s)
end
end
across
sreg_keys as c
loop
s := c.item
if attached item_by_name (s, lst) as v then
attributes.force (v, s.substring (5, s.count))
end
end
end
end
get_ax_attributes (lst: like values)
local
s: READABLE_STRING_32
ax_keys: ARRAYED_LIST [READABLE_STRING_32]
l_alias: detachable READABLE_STRING_8
k_value, k_type, k_count: READABLE_STRING_8
k: STRING_8
i: INTEGER
do
if lst /= Void and then attached item_by_name ("openid.signed", lst) as l_signed then
-- ax attributes
across
l_signed.split (',') as c
loop
i := i + 1
s := c.item
if s.starts_with ({STRING_32} "ns.") then
if attached item_by_name ({STRING_32} "openid." + s, lst) as v then
if s.same_string ({STRING_32} "ns.ax") and v.same_string ({STRING_32} "http://openid.net/srv/ax/1.0") then
l_alias := "ax."
else
if v.same_string ("http://openid.net/srv/ax/1.0") then
l_alias := s.substring (("ns.").count + 1, s.count).to_string_8 + "."
end
end
end
end
end
if l_alias /= Void then
k_value := l_alias + "value."
k_type := l_alias + "type."
k_count := l_alias + "count."
create ax_keys.make (i)
across
l_signed.split (',') as c
loop
s := c.item
if
s.starts_with (k_value)
or s.starts_with (k_type)
then
ax_keys.force ("openid." + s)
end
end
k_value := "openid." + k_value
k_type := "openid." + k_type
k_count := "openid." + k_count
across
ax_keys as c
loop
s := c.item
if attached item_by_name (s, lst) as v then
if s.starts_with (k_value) then
k := s.substring (k_value.count + 1, s.count)
i := k.index_of ('.', 1)
if i > 1 then
k.keep_head (i - 1)
end
if attached item_by_name (k_type + k, lst) as l_type then
if l_type.starts_with ("http://axschema.org/") then
check ("http://axschema.org/").count = 20 end
attributes.force (v, l_type.substring (21, l_type.count))
elseif l_type.starts_with ("http://schema.openid.net/") then
check ("http://schema.openid.net/").count = 25 end
attributes.force (v, l_type.substring (26, l_type.count))
else
-- unsupported schema domain.
end
else
-- no alias !!!
end
-- attributes.force (v, k)
end
end
end
end
end
end
item_by_name (a_name: READABLE_STRING_GENERAL; lst: like values): detachable READABLE_STRING_32
local
l_found: BOOLEAN
do
if lst /= Void then
across
lst as c
until
l_found
loop
if a_name.same_string (c.item.name) then
Result := c.item.value
l_found := True
end
end
end
end
feature -- Access
is_valid: BOOLEAN
end

View File

@@ -0,0 +1,59 @@
note
description: "Summary description for {OPENID_DISCOVER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
OPENID_DISCOVER
create
make
feature {NONE} -- Initialization
make (a_server_uri: READABLE_STRING_8; a_version: like version)
do
version := a_version
server_uri := a_server_uri
end
feature -- Access
version: INTEGER
server_uri: READABLE_STRING_8
delegate: detachable READABLE_STRING_8 assign set_delegate
ax_supported: BOOLEAN assign set_ax_supported
sreg_supported: BOOLEAN assign set_sreg_supported
identifier_select: BOOLEAN assign set_identifier_select
has_error: BOOLEAN assign set_has_error
feature -- Change
set_delegate (v: like delegate)
do
delegate := v
end
set_ax_supported (v: like ax_supported)
do
ax_supported := v
end
set_sreg_supported (v: like sreg_supported)
do
sreg_supported := v
end
set_identifier_select (v: like identifier_select)
do
identifier_select := v
end
set_has_error (v: like has_error)
do
has_error := v
end
end

View File

@@ -0,0 +1,31 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
test_openid
end
test_openid
local
t: TEST_OPENID
do
create t.make
end
end

View File

@@ -0,0 +1,69 @@
note
description: "Summary description for {TEST_OPENID}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
TEST_OPENID
create
make
feature
make
local
o: OPENID_CONSUMER
v: OPENID_CONSUMER_VALIDATION
id: READABLE_STRING_8
do
id := "https://www.google.com/accounts/o8/id"
create o.make ("http://localhost")
if attached o.auth_url (id) as l_url then
check o.error = Void end
get_openid_response_uri (l_url)
if attached openid_response_uri as u and then u.is_valid then
create v.make_from_items (o, u.decoded_query_items)
v.validate
if v.is_valid then
print ("Succeed ...%N")
else
print ("Failed !!!%N")
end
else
print ("Failed !!!%N")
end
elseif attached o.error as l_err then
print (l_err)
else
print ("???")
end
end
get_openid_response_uri (a_auth_url: READABLE_STRING_8)
local
f: RAW_FILE
e: EXECUTION_ENVIRONMENT
do
openid_response_uri := Void
create f.make_create_read_write ("openid_tmp.html")
f.put_string ("<a href=%"" + a_auth_url + "%">Click to authenticate with openid</a>")
f.put_new_line
f.close
create e
e.system ("start " + f.name)
io.put_string ("Returned URL (copy/paste the url from your browser's address bar )?%N")
io.read_line
create openid_response_uri.make_from_string (io.last_string)
end
openid_response_uri: detachable URI
feature -- Access
end

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="tests" uuid="A36A6621-CF4A-4FB6-8CB2-D420D630A134">
<target name="tests">
<root class="APPLICATION" feature="make"/>
<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="standard">
</option>
<setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="openid" location="..\openid-safe.ecf" readonly="false"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri-safe.ecf"/>
<tests name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -10,6 +10,17 @@
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
</option>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<cluster name="src" location="./src" recursive="true"/>
<cluster name="src" location=".\src\" recursive="false">
<cluster name="before_72" location="$|before_72\">
<condition>
<version type="compiler" max="7.1.9.9999"/>
</condition>
</cluster>
<cluster name="greater_or_72" location="$|greater_or_72\">
<condition>
<version type="compiler" min="7.2.0.0"/>
</condition>
</cluster>
</cluster>
</target>
</system>

View File

@@ -44,6 +44,7 @@ feature -- Execution
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make, Current)
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make, create {WGI_CGI_ERROR_STREAM}.make)
service.execute (req, res)
res.push
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
@@ -53,6 +54,7 @@ feature -- Execution
if res.message_writable then
res.put_string ("<pre>" + l_trace + "</pre>")
end
res.push
end
end
end

View File

@@ -65,6 +65,7 @@ feature -- Execution
create req.make (vars, a_input, Current)
create res.make (a_output, a_output)
service.execute (req, res)
res.push
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
@@ -74,6 +75,7 @@ feature -- Execution
if res.message_writable then
res.put_string ("<pre>" + l_trace + "</pre>")
end
res.push
end
end
end

View File

@@ -23,6 +23,10 @@ feature {NONE} -- Initialization
create cfg.make
create server.make (cfg)
-- Callbacks
create on_launched_actions
create on_stopped_actions
end
make_with_base (a_service: like service; a_base: like base)
@@ -69,6 +73,14 @@ feature -- Status report
-- Listening port.
--| 0: not launched
feature -- Callbacks
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when launched
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when stopped
feature -- Element change
on_launched (a_port: INTEGER)
@@ -76,11 +88,13 @@ feature -- Element change
do
launched := True
port := a_port
on_launched_actions.call ([Current])
end
on_stopped
-- Server stopped
do
on_stopped_actions.call ([Current])
launched := False
port := 0
end
@@ -119,10 +133,10 @@ feature -- Server
res: detachable WGI_NINO_RESPONSE_STREAM
do
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), Void)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), create {WGI_NINO_ERROR_STREAM}.make_stderr (a_socket.descriptor.out))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
res.commit
res.push
end
note

View File

@@ -0,0 +1,70 @@
note
description: "Summary description for WGI_CGI_ERROR_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
WGI_NINO_ERROR_STREAM
inherit
WGI_ERROR_STREAM
create
make,
make_stderr,
make_stdout
feature {NONE} -- Initialization
make (a_identifier: READABLE_STRING_8; a_file: PLAIN_TEXT_FILE)
do
identifier := a_identifier
output := a_file
end
make_stderr (a_identifier: READABLE_STRING_8)
do
make (a_identifier, io.error)
end
make_stdout (a_identifier: READABLE_STRING_8)
do
make (a_identifier, io.error)
end
feature -- Access
identifier: READABLE_STRING_8
output: FILE
feature -- Error
put_error (a_message: READABLE_STRING_8)
local
s: STRING
do
create s.make (a_message.count + identifier.count + 4)
s.append_character ('[')
s.append (identifier)
s.append_character (']')
s.append_character (' ')
s.append (a_message)
s.append_character ('%N')
-- Display it at once.
output.put_string (s)
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

View File

@@ -17,6 +17,7 @@ feature {NONE} -- Initialization
make_with_response (res: WGI_RESPONSE)
do
wgi_response := res
res.set_post_commit_action (agent commit)
end
wgi_response: WGI_RESPONSE
@@ -26,7 +27,7 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
commit
-- Commit the current response
do
-- do nothing, this will be done internal on the original `wgi_response' object
wgi_response.set_post_commit_action (Void)
end
feature -- Status report
@@ -129,7 +130,7 @@ feature -- Error reporting
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -8,6 +8,15 @@ deferred class
feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
push
-- Commit and push response
do
commit
if attached post_commit_action as act then
act.call (Void)
end
end
commit
-- Commit the current response
deferred
@@ -17,6 +26,21 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
message_committed: message_committed
end
feature -- Access: commit
post_commit_action: detachable PROCEDURE [ANY, TUPLE]
-- Action associated with the final `commit' execution
-- Note: useful to trigger action just after the
-- response is transfered to the client.
feature -- Change: commit
set_post_commit_action (act: like post_commit_action)
-- Assign `act' to `post_commit_action'
do
post_commit_action := act
end
feature -- Status report
status_committed: BOOLEAN
@@ -131,7 +155,7 @@ feature -- Error reporting
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -34,7 +34,12 @@ create
feature {NONE} -- Initialization
initialize
local
conn: like connector
do
create on_launched_actions
create on_stopped_actions
port_number := 80 --| Default, but quite often, this port is already used ...
base_url := ""
@@ -64,14 +69,15 @@ feature {NONE} -- Initialization
verbose := l_verbose_str.as_lower.same_string ("true")
end
end
create connector.make (Current)
if attached connector as conn then
conn.set_base (base_url)
if single_threaded then
conn.configuration.set_force_single_threaded (True)
end
conn.configuration.set_is_verbose (verbose)
create conn.make (Current)
conn.on_launched_actions.extend (agent on_launched)
conn.on_stopped_actions.extend (agent on_stopped)
connector := conn
conn.set_base (base_url)
if single_threaded then
conn.configuration.set_force_single_threaded (True)
end
conn.configuration.set_is_verbose (verbose)
end
feature -- Execution
@@ -104,8 +110,26 @@ feature -- Execution
end
end
feature -- Callback
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when launched
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when stopped
feature {NONE} -- Implementation
on_launched (conn: WGI_CONNECTOR)
do
on_launched_actions.call ([conn])
end
on_stopped (conn: WGI_CONNECTOR)
do
on_stopped_actions.call ([conn])
end
port_number: INTEGER
server_name: detachable READABLE_STRING_8
@@ -123,11 +147,11 @@ feature -- Status report
launchable: BOOLEAN
do
Result := Precursor and port_number > 0
Result := Precursor and port_number >= 0
end
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -203,7 +203,9 @@ feature -- Execution
end
if
attached req.meta_string_variable ("HTTP_IF_MODIFIED_SINCE") as s_if_modified_since and then
attached file_date (f) as f_date and then (f_date >= rfc1123_http_date_format_to_date (s_if_modified_since))
attached http_date_format_to_date (s_if_modified_since) as l_if_modified_since_date and then
attached file_date (f) as f_date and then
f_date <= l_if_modified_since_date
then
process_not_modified (f_date, req, res)
else
@@ -425,35 +427,59 @@ feature {NONE} -- Implementation
feature {NONE} -- implementation: date time
date_time_utility: HTTP_DATE_TIME_UTILITIES
once
create Result
end
file_date (f: FILE): DATE_TIME
do
Result := timestamp_to_date (f.date)
end
rfc1123_http_date_format_to_date (s: STRING): DATE_TIME
http_date_format_to_date (s: READABLE_STRING_8): detachable DATE_TIME
-- String representation of `dt' using the RFC 1123
-- HTTP-date = rfc1123-date | rfc850-date | asctime-date
-- rfc1123-date = wkday "," SP date1 SP time SP "GMT"
-- rfc850-date = weekday "," SP date2 SP time SP "GMT"
-- asctime-date = wkday SP date3 SP time SP 4DIGIT
-- date1 = 2DIGIT SP month SP 4DIGIT
-- ; day month year (e.g., 02 Jun 1982)
-- date2 = 2DIGIT "-" month "-" 2DIGIT
-- ; day-month-year (e.g., 02-Jun-82)
-- date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
-- ; month day (e.g., Jun 2)
-- time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
-- ; 00:00:00 - 23:59:59
-- wkday = "Mon" | "Tue" | "Wed"
-- | "Thu" | "Fri" | "Sat" | "Sun"
-- weekday = "Monday" | "Tuesday" | "Wednesday"
-- | "Thursday" | "Friday" | "Saturday" | "Sunday"
-- month = "Jan" | "Feb" | "Mar" | "Apr"
-- | "May" | "Jun" | "Jul" | "Aug"
-- | "Sep" | "Oct" | "Nov" | "Dec"
--| Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
--| Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
--| Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
--|
--| "ddd, [0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2"
--| ex: "WED, 30 JAN 2013 21:34:33 "
note
EIS: "name=RFC2616", "protocol=URI", "src=http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html"
local
t: STRING
d: HTTP_DATE
do
t := s
if t.ends_with ("GMT") then
t := t.substring (1, t.count - 4)
create d.make_from_string (s)
if not d.has_error then
Result := d.date_time
end
create Result.make_from_string (t, "ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2")
end
timestamp_to_date (n: INTEGER): DATE_TIME
local
d: HTTP_DATE
do
Result := date_time_utility.unix_time_stamp_to_date_time (n)
create d.make_from_timestamp (n)
Result := d.date_time
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

View File

@@ -151,7 +151,9 @@ feature {NONE} -- Storage
build
end
rescue
io.error.put_string ("Error while loading Cookie session...!%N")
debug ("wsf")
io.error.put_string ("Error while loading Cookie session...!%N")
end
end
build

View File

@@ -0,0 +1,108 @@
note
description: "Summary description for {WGI_DELAYED_HEADER_RESPONSE}."
date: "$Date$"
revision: "$Revision$"
class
WSF_WGI_DELAYED_HEADER_RESPONSE
inherit
WGI_FILTER_RESPONSE
redefine
commit,
put_character,
put_string,
put_substring,
flush,
message_writable
end
WSF_RESPONSE_EXPORTER
create
make
feature {NONE} -- Initialization
make (r: WGI_RESPONSE; res: WSF_RESPONSE)
do
wsf_response := res
make_with_response (r)
end
feature {NONE} -- Implementation
wsf_response: WSF_RESPONSE
commit
do
Precursor
if not header_committed then
process_header
end
end
process_header
require
header_not_committed: not header_committed
do
-- If no content is sent, the final `{WGI_REPONSE}.push' will call `process_header'
-- via `{WGI_RESPONSE}.post_commit_action'
wgi_response.set_post_commit_action (Void)
-- commit status code and reason phrase
-- commit header text
wsf_response.process_header
-- update wgi_response on wsf_response to send content directly
wsf_response.set_wgi_response (wgi_response)
ensure
header_committed: header_committed
end
feature -- Status report
message_writable: BOOLEAN = True
-- Can message be written?
feature -- Output operation
put_character (c: CHARACTER_8)
-- Send the character `c'
do
process_header
Precursor (c)
end
put_string (s: READABLE_STRING_8)
-- Send the string `s'
do
process_header
Precursor (s)
end
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
-- Send the substring `s[a_begin_index:a_end_index]'
do
process_header
Precursor (s, a_begin_index, a_end_index)
end
flush
-- Flush if it makes sense
do
process_header
Precursor
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

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
make_with_value (a_value: WSF_VALUE)
do
name := a_value.name
create {LINKED_LIST [WSF_STRING]} values.make
create {ARRAYED_LIST [WSF_STRING]} values.make (3)
add_value (a_value)
end
@@ -59,6 +59,12 @@ feature -- Access
name: READABLE_STRING_32
url_encoded_name: READABLE_STRING_8
-- URL encoded string of `name'.
do
Result := url_encoder.encoded_string (name)
end
values: LIST [WSF_STRING]
frozen string_values: like values
@@ -174,7 +180,7 @@ invariant
string_values_not_empty: values.count >= 1
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

View File

@@ -16,6 +16,11 @@ feature -- Access
deferred
end
url_encoded_name: READABLE_STRING_8
-- URL encoded string of `name'.
deferred
end
frozen key: like name
do
Result := name

View File

@@ -347,7 +347,7 @@ feature {NONE} -- Access: global variable
end
end
feature -- Access: global variable
feature -- Access: global variables
items: ITERABLE [WSF_VALUE]
do
@@ -380,7 +380,11 @@ feature -- Access: global variable
string_array_item (a_name: READABLE_STRING_GENERAL): detachable ARRAY [READABLE_STRING_32]
-- Array of string values for path parameter `a_name' if relevant.
do
Result := string_array_item_for (a_name, agent item)
if attached {WSF_TABLE} item (a_name) as tb then
Result := tb.as_array_of_string
else
Result := string_array_item_for (a_name, agent item)
end
end
string_array_item_for (a_name: READABLE_STRING_GENERAL; a_item_fct: FUNCTION [ANY, TUPLE [READABLE_STRING_GENERAL], detachable WSF_VALUE]): detachable ARRAY [READABLE_STRING_32]
@@ -407,6 +411,43 @@ feature -- Access: global variable
Result.keep_head (n - 1)
end
feature -- Helpers: global variables
items_as_string_items: ITERABLE [TUPLE [name: READABLE_STRING_32; value: detachable READABLE_STRING_32]]
-- `items' as strings items
-- i.e: flatten any table or related into multiple string items
local
res: ARRAYED_LIST [TUPLE [name: READABLE_STRING_32; value: detachable READABLE_STRING_32]]
do
if attached items_table as tb then
create res.make (tb.count)
across
tb as c
loop
append_value_as_string_items_to (c.item, res)
end
else
create res.make (0)
end
Result := res
end
append_value_as_string_items_to (v: WSF_VALUE; a_target: LIST [TUPLE [name: READABLE_STRING_32; value: detachable READABLE_STRING_32]])
-- Append value `v' to `a_target' as multiple string items
do
if attached {WSF_STRING} v as s then
a_target.force ([s.name, s.value])
elseif attached {ITERABLE [WSF_VALUE]} v as lst then
across
lst as c
loop
append_value_as_string_items_to (c.item, a_target)
end
else
a_target.force ([v.name, v.string_representation])
end
end
feature -- Execution variables
execution_variable (a_name: READABLE_STRING_GENERAL): detachable ANY
@@ -1796,7 +1837,7 @@ invariant
wgi_request.content_type /= Void implies content_type /= Void
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

View File

@@ -28,16 +28,32 @@ convert
feature {NONE} -- Initialization
make_from_wgi (r: WGI_RESPONSE)
local
wres: detachable WSF_WGI_DELAYED_HEADER_RESPONSE
do
transfered_content_length := 0
wgi_response := r
create header.make
wgi_response := r
create wres.make (r, Current)
wgi_response := wres
set_status_code ({HTTP_STATUS_CODE}.ok) -- Default value
end
feature {WSF_RESPONSE_EXPORTER} -- Properties
wgi_response: WGI_RESPONSE
-- Associated WGI_RESPONSE
-- Associated WGI_RESPONSE.
header: WSF_HEADER
-- Associated response header.
feature {WSF_RESPONSE_EXPORTER} -- Change
set_wgi_response (res: WGI_RESPONSE)
-- Set associated WGI_RESPONSE
do
wgi_response := res
end
feature -- Status report
@@ -77,6 +93,7 @@ feature -- Status setting
-- Set response status code
-- Should be done before sending any data back to the client
--| note: the status is really sent when the header are set
--| Default value might be set to 200 {HTTP_HEADER}.ok.
require
a_code_valid: a_code > 0
status_not_set: not status_committed
@@ -113,19 +130,60 @@ feature -- Status setting
status_reason_phrase: detachable READABLE_STRING_8
-- Custom status reason phrase (optional)
feature {WSF_RESPONSE_EXPORTER} -- Header output operation
process_header
require
header_not_committed: not header_committed
do
if not header_committed then
-- 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)
end
ensure
status_committed: status_committed
header_committed: header_committed
end
report_content_already_sent_and_header_ignored
do
put_error ("Content already sent, new header text ignored!")
end
feature -- Header output operation
header: HTTP_HEADER
-- Header
-- This is useful when we want to fill the `header'
-- in two pass (i.e. in two different classes).
-- We first call features of `header', and finally
-- we call `put_header_text'
put_header_line (h: READABLE_STRING_8)
-- Put header `h'
-- Replace any existing value
require
header_not_committed: not header_committed
do
if header_committed then
report_content_already_sent_and_header_ignored
else
header.put_header (h)
end
end
add_header_line (h: READABLE_STRING_8)
-- Add header `h'
-- This can lead to duplicated header entries
require
header_not_committed: not header_committed
do
if header_committed then
report_content_already_sent_and_header_ignored
else
header.add_header (h)
end
end
put_header_text (a_text: READABLE_STRING_8)
-- Sent `a_text' and just before send the status code
-- Put the multiline header `a_text'
-- Overwite potential existing header
require
status_set: status_is_set
header_not_committed: not header_committed
a_text_ends_with_single_crlf: a_text.count > 2 implies not a_text.substring (a_text.count - 2, a_text.count).same_string ("%R%N")
a_text_does_not_end_with_double_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N")
@@ -133,62 +191,88 @@ feature -- Header output operation
l_text: READABLE_STRING_8
l_header: HTTP_HEADER
do
wgi_response.set_status_code (status_code, status_reason_phrase)
if header.is_empty then
l_text := a_text
if header_committed then
report_content_already_sent_and_header_ignored
else
create l_header.make_from_raw_header_data (a_text)
across
l_header as c
loop
header.put_header (c.item.string)
end
l_text := header.string
header.append_raw_header_data (a_text)
end
wgi_response.put_header_text (l_text)
ensure
status_set: status_is_set
status_committed: status_committed
header_committed: header_committed
message_writable: message_writable
end
add_header_text (a_text: READABLE_STRING_8)
-- Add the multiline header `a_text'
-- Does not replace existing header with same name
-- This could leads to multiple header with the same name
require
header_not_committed: not header_committed
a_text_ends_with_single_crlf: a_text.count > 2 implies not a_text.substring (a_text.count - 2, a_text.count).same_string ("%R%N")
a_text_does_not_end_with_double_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N")
do
if header_committed then
report_content_already_sent_and_header_ignored
else
header.append_raw_header_data (a_text)
end
ensure
status_set: status_is_set
message_writable: message_writable
end
feature -- Header output operation: helpers
put_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Send headers with status `a_status', and headers from `a_headers'
-- Put headers with status `a_status', and headers from `a_headers'
require
status_not_committed: not status_committed
header_not_committed: not header_committed
local
h: HTTP_HEADER
do
set_status_code (a_status_code)
if a_headers /= Void then
create h.make_from_array (a_headers)
put_header_text (h.string)
end
ensure
status_set: status_is_set
header_committed: header_committed
message_writable: message_writable
end
add_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Put headers with status `a_status', and headers from `a_headers'
require
status_not_committed: not status_committed
header_not_committed: not header_committed
local
h: HTTP_HEADER
do
if a_headers /= Void then
create h.make_from_array (a_headers)
add_header_text (h.string)
end
ensure
status_set: status_is_set
message_writable: message_writable
end
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Send headers from `a_lines'
local
h: STRING_8
-- Put headers from `a_lines'
require
header_not_committed: not header_committed
do
create h.make (256)
across
a_lines as c
loop
h.append (c.item.name)
h.append_character (':')
h.append_character (' ')
h.append (c.item.value)
h.append_character ('%R')
h.append_character ('%N')
across a_lines as c loop
put_header_line (c.item.name + ": " + c.item.value)
end
end
add_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Add headers from `a_lines'
require
header_not_committed: not header_committed
do
across a_lines as c loop
add_header_line (c.item.name + ": " + c.item.value)
end
put_header_text (h)
end
feature -- Output report

View File

@@ -8,6 +8,7 @@ note
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
EIS: "name=URI Template RFC6570", "protocol=URI", "src=http://tools.ietf.org/html/rfc6570"
class
URI_TEMPLATE