|
16 | 16 | And also has |
17 | 17 | execution_variable (a_name: READABLE_STRING_GENERAL): detachable ANY |
18 | 18 | --| to keep value attached to the request |
| 19 | +
|
| 20 | + About https support: `is_https' precises if the request is made through an https connection or not. |
| 21 | + |
19 | 22 | ]" |
20 | 23 | date: "$Date$" |
21 | 24 | revision: "$Revision$" |
@@ -120,6 +123,21 @@ feature {NONE} -- Initialization |
120 | 123 | if meta_variable ({WSF_META_NAMES}.request_time) = Void then |
121 | 124 | set_meta_string_variable ({WSF_META_NAMES}.request_time, date_time_utilities.unix_time_stamp (Void).out) |
122 | 125 | end |
| 126 | + |
| 127 | + --| HTTPS support |
| 128 | + if attached meta_string_variable ("REQUEST_SCHEME") as l_scheme and then not l_scheme.is_empty then |
| 129 | + is_https := l_scheme.is_case_insensitive_equal_general ("https") |
| 130 | + elseif attached execution_environment.item ("HTTPS") as l_https and then not l_https.is_empty then |
| 131 | + is_https := l_https.is_case_insensitive_equal_general ("on") |
| 132 | + or else l_https.is_case_insensitive_equal_general ("yes") |
| 133 | + or else l_https.is_case_insensitive_equal_general ("true") |
| 134 | + or else l_https.is_case_insensitive_equal_general ("1") |
| 135 | + --| Usually, if not empty, this means this is https |
| 136 | + --| but it occurs that server (like IIS) sets "off" when this is NOT https |
| 137 | + --| so, let's be flexible, and accepts other variants of "on" |
| 138 | + else |
| 139 | + check is_not_https: is_https = False end |
| 140 | + end |
123 | 141 | end |
124 | 142 |
|
125 | 143 | wgi_request: WGI_REQUEST |
@@ -160,6 +178,10 @@ feature -- Destroy |
160 | 178 |
|
161 | 179 | feature -- Status report |
162 | 180 |
|
| 181 | + is_https: BOOLEAN |
| 182 | + -- Is https scheme or protocol? |
| 183 | + --| based on REQUEST_SCHEME, or environment variable HTTPS=on |
| 184 | + |
163 | 185 | debug_output: STRING_8 |
164 | 186 | do |
165 | 187 | create Result.make_from_string (request_method + " " + request_uri) |
@@ -1738,19 +1760,22 @@ feature -- URL Utility |
1738 | 1760 | do |
1739 | 1761 | s := internal_server_url |
1740 | 1762 | if s = Void then |
1741 | | - if |
1742 | | - server_protocol.count >= 5 and then |
1743 | | - server_protocol.substring (1, 5).is_case_insensitive_equal ("https") |
1744 | | - then |
| 1763 | + if is_https then |
1745 | 1764 | create s.make_from_string ("https://") |
1746 | 1765 | else |
1747 | 1766 | create s.make_from_string ("http://") |
1748 | 1767 | end |
1749 | 1768 | s.append (server_name) |
1750 | 1769 | p := server_port |
1751 | 1770 | if p > 0 then |
1752 | | - s.append_character (':') |
1753 | | - s.append_integer (p) |
| 1771 | + if is_https and p = 443 then |
| 1772 | + -- :443 is default for https, so no need to put it |
| 1773 | + elseif not is_https and p = 80 then |
| 1774 | + -- :80 is default for http, so no need to put it |
| 1775 | + else |
| 1776 | + s.append_character (':') |
| 1777 | + s.append_integer (p) |
| 1778 | + end |
1754 | 1779 | end |
1755 | 1780 | end |
1756 | 1781 | Result := s |
|
0 commit comments