diff --git a/library/network/protocol/http/src/http_cookie.e b/library/network/protocol/http/src/http_cookie.e index 92503db3..941a47c5 100644 --- a/library/network/protocol/http/src/http_cookie.e +++ b/library/network/protocol/http/src/http_cookie.e @@ -1,21 +1,21 @@ note description: "[ - This class represents the value of a HTTP cookie, transferred in a request. - The class has features to build an HTTP cookie. + This class represents the value of a HTTP cookie, transferred in a request. + The class has features to build an HTTP cookie. - Following a newer RFC standard for Cookies http://tools.ietf.org/html/rfc6265 + Following a newer RFC standard for Cookies http://tools.ietf.org/html/rfc6265 - Domain - * WARNING: Some existing user agents treat an absent Domain attribute as if the Domain attribute were present and contained the current host name. - * For example, if example.com returns a Set-Cookie header without a Domain attribute, these user agents will erroneously send the cookie to www.example.com as well. + Domain + * WARNING: Some existing user agents treat an absent Domain attribute as if the Domain attribute were present and contained the current host name. + * For example, if example.com returns a Set-Cookie header without a Domain attribute, these user agents will erroneously send the cookie to www.example.com as well. - Max-Age, Expires - * If a cookie has both the Max-Age and the Expires attribute, the Max-Age attribute has precedence and controls the expiration date of the cookie. - * If a cookie has neither the Max-Age nor the Expires attribute, the user agent will retain the cookie until "the current session is over" (as defined by the user agent). - * You will need to call the feature + Max-Age, Expires + * If a cookie has both the Max-Age and the Expires attribute, the Max-Age attribute has precedence and controls the expiration date of the cookie. + * If a cookie has neither the Max-Age nor the Expires attribute, the user agent will retain the cookie until "the current session is over" (as defined by the user agent). + * You will need to call the feature - HttpOnly, Secure - * Note that the HttpOnly attribute is independent of the Secure attribute: a cookie can have both the HttpOnly and the Secure attribute. + HttpOnly, Secure + * Note that the HttpOnly attribute is independent of the Secure attribute: a cookie can have both the HttpOnly and the Secure attribute. ]" date: "$Date$" @@ -32,7 +32,10 @@ feature {NONE} -- Initialization make (a_name: READABLE_STRING_8; a_value: READABLE_STRING_8) -- Create an object instance of cookie with name `a_name' and value `a_value'. require - make_sense: (a_name /= Void and a_value /= Void) and then (not a_name.is_empty and not a_value.is_empty) + a_name_not_blank: a_name /= Void and then not a_name.is_whitespace + a_value_not_empty: a_value /= Void and then not a_value.is_empty + a_name_has_valid_characters: a_name /= Void and then has_valid_characters (a_name) + a_value_has_valid_characters: a_value /= Void and then has_valid_characters (a_value) do set_name (a_name) set_value(a_value) @@ -66,33 +69,33 @@ feature -- Access secure: BOOLEAN -- Value of the Secure attribute. -- By default False. - --| Idicate if the cookie should only be sent over secured(encrypted connections, for example SSL). + --| Indicate if the cookie should only be sent over secured(encrypted connections, for example SSL). http_only: BOOLEAN -- Value of the http_only attribute. -- By default false. - --| Limits the scope of the cookie to HTTP requests. + --| Limits the scope of the cookie to HTTP requests. max_age: INTEGER -- Value of the Max-Age attribute. - --| How much time in seconds should elapsed before the cooki expires. + --| How much time in seconds should elapsed before the cookie expires. --| By default max_age < 0 indicate a cookie will last only for the current user-agent (Browser, etc) session. --| A value of 0 instructs the user-agent to delete the cookie. - has_valid_characters (a_name: READABLE_STRING_GENERAL):BOOLEAN + has_valid_characters (a_name: READABLE_STRING_8):BOOLEAN -- Has `a_name' valid characters for cookies? local l_iterator: STRING_ITERATION_CURSOR l_found: BOOLEAN do create l_iterator.make (a_name) - + Result := True across l_iterator as ic until l_found loop - if is_valid_character (ic.item.to_character_8) then + if not is_valid_character (ic.item.to_character_8) then Result := False l_found := True end @@ -100,37 +103,43 @@ feature -- Access end include_max_age: BOOLEAN - -- Does the Set-Cookie header will include Max-Age attribute? + -- Does the Set-Cookie header include Max-Age attribute? --|By default will include both. include_expires: BOOLEAN - -- Does the Set-Cookie header will include Expires attribute? + -- Does the Set-Cookie header include Expires attribute? --|By default will include both. feature -- Change Element - set_name (a_name: READABLE_STRING_GENERAL) + set_name (a_name: READABLE_STRING_8) -- Set `name' with `a_name'. + require + a_name_not_blank: a_name /= Void and then not a_name.is_whitespace + a_name_has_valid_characters: a_name /= Void and then has_valid_characters (a_name) do - name := a_name.as_string_8 + name := a_name ensure name_set: name = a_name end - set_value (a_value: READABLE_STRING_GENERAL) + set_value (a_value: READABLE_STRING_8) -- Set `value' with `a_value'. + require + a_value_not_empty: a_value /= Void and then not a_value.is_empty + a_value_has_valid_characters: a_value /= Void and then has_valid_characters (a_value) do - value := a_value.as_string_8 + value := a_value ensure value_set: value = a_value end - set_expiration (a_date: READABLE_STRING_GENERAL) + set_expiration (a_date: READABLE_STRING_8) -- Set `expiration' with `a_date' do - expiration := a_date.as_string_32 + expiration := a_date ensure - expiration_set: attached expiration as l_expiration and then l_expiration.same_string (a_date.as_string_8) + expiration_set: attached expiration as l_expiration and then l_expiration.same_string (a_date) end set_expiration_date (a_date: DATE_TIME) @@ -141,22 +150,22 @@ feature -- Change Element expiration_set: attached expiration as l_expiration and then l_expiration.same_string (date_to_rfc1123_http_date_format (a_date)) end - set_path (a_path: READABLE_STRING_GENERAL) + set_path (a_path: READABLE_STRING_8) -- Set `path' with `a_path' do - path := a_path.as_string_8 + path := a_path ensure path_set: path = a_path end - set_domain (a_domain: READABLE_STRING_GENERAL) + set_domain (a_domain: READABLE_STRING_8) -- Set `domain' with `a_domain' -- Note: you should avoid using "localhost" as `domain' for local cookies -- since they are not always handled by browser (for instance Chrome) require domain_without_port_info: a_domain /= Void implies a_domain.index_of (':', 1) = 0 do - domain := a_domain.as_string_8 + domain := a_domain ensure domain_set: domain = a_domain end @@ -218,11 +227,11 @@ feature -- Change Element include_expires := False include_max_age := False ensure - expires_false: not include_expires - max_age_false: not include_max_age + expires_false: not include_expires + max_age_false: not include_max_age end -feature -- Date Utils +feature {NONE} -- Date Utils date_to_rfc1123_http_date_format (dt: DATE_TIME): STRING_8 -- String representation of `dt' using the RFC 1123 @@ -236,7 +245,7 @@ feature -- Date Utils feature -- Output header_line: STRING - -- String representation of Set-Cookie header of current. + -- String representation of Set-Cookie header line of Current. local s: STRING do @@ -260,17 +269,21 @@ feature -- Output -- Max-Age elseif include_max_age then s.append ("; Max-Age=") - s.append (max_age.out) + s.append_integer (max_age) else -- Default - check default: (not include_expires) and (not include_max_age) end + check + -- By default the attributes include_expires and include_max_age are False. + -- Meaning that Expires and Max-Age headers are included in the response. + default: (not include_expires) and (not include_max_age) + end if attached expiration as l_expires then s.append ("; Expires=") s.append (l_expires) end s.append ("; Max-Age=") - s.append (max_age.out) + s.append_integer (max_age) end if secure then @@ -291,24 +304,8 @@ feature {NONE} -- Constants end - legal_characters, valid_characters: SPECIAL [CHARACTER_8] - -- RFC6265 that specifies that the following is valid for characters in cookies. Cookies are also supposed to be double quoted. - -- The following character ranges are valid:http://tools.ietf.org/html/rfc6265#section-4.1.1 - -- %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E - -- 0x21: ! - -- 0x23-2B: #$%&'()*+ - -- 0x2D-3A: -./0123456789: - -- 0x3C-5B: <=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[ - -- 0x5D-7E: ]^_`abcdefghijklmnopqrstuvwxyz{|}~ - note - EIS: "name=valid-characters", "src=http://tools.ietf.org/html/rfc6265#section-4.1.1", "protocol=uri" - once - Result := ("!#$%%&'()*+-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~").area - end - - is_valid_character (c: CHARACTER): BOOLEAN - -- RFC6265 that specifies that the following is valid for characters in cookies. Cookies are also supposed to be double quoted. + -- RFC6265 that specifies that the following is valid for characters in cookies. -- The following character ranges are valid:http://tools.ietf.org/html/rfc6265#section-4.1.1 -- %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E -- 0x21: ! diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index ce6f9ea8..3dac3fc3 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -325,19 +325,16 @@ feature -- Header add cookie --| the same response with the same cookie-name. local l_same_cookie_name: BOOLEAN - l_cookie_header: STRING - l_cn: STRING l_nv: STRING do - across internal_header.headers as ic until l_same_cookie_name loop + across + internal_header.headers as ic + until l_same_cookie_name + loop if ic.item.starts_with ("Set-Cookie") then - l_cookie_header := ic.item.twin - l_cookie_header.to_lower - l_cn := a_cookie.name - l_cn.to_lower - l_nv := l_cookie_header.split (';').at (1).split (':').at (2) + l_nv := ic.item.split (';').at (1).split (':').at (2) l_nv.adjust - if l_nv.starts_with (l_cn) then + if l_nv.starts_with (a_cookie.name) then l_same_cookie_name := True end end diff --git a/library/server/wsf/tests/src/wgi_response_null.e b/library/server/wsf/tests/src/wgi_response_null.e index 8bf6795c..035413c1 100644 --- a/library/server/wsf/tests/src/wgi_response_null.e +++ b/library/server/wsf/tests/src/wgi_response_null.e @@ -1,5 +1,9 @@ note - description: "Summary description for {WGI_RESPONSE_NULL}." + description: "[ + Mock implementation of the WGI_RESPONSE interface. + + Used for testing the ewf core and also web applications. + ]" date: "$Date$" revision: "$Revision$" diff --git a/library/server/wsf/tests/src/wsf_service_null.e b/library/server/wsf/tests/src/wsf_service_null.e index c35a7a83..4f6cf001 100644 --- a/library/server/wsf/tests/src/wsf_service_null.e +++ b/library/server/wsf/tests/src/wsf_service_null.e @@ -1,6 +1,9 @@ note - description: "Summary description for {WSF_SERVICE_NULL}." - author: "" + description: "[ + Mock implementation of the WGI_SERVICE interface. + + Used for testing the ewf core and also web applications + ]" date: "$Date$" revision: "$Revision$"