Extracted network socket classes from httpd folder, and created a new library/network/http_network library.

Renamed HTTPD_STREAM_SOCKET as HTTP_STREAM_SOCKET.
Made http_client (net) library use the new http_network library.
This commit is contained in:
2016-10-12 23:27:55 +02:00
parent c132d7734b
commit 981942b2d6
30 changed files with 160 additions and 102 deletions

View File

@@ -13,8 +13,12 @@
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/> <library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
<library name="http" location="..\protocol\http\http-safe.ecf"/> <library name="http" location="..\protocol\http\http-safe.ecf"/>
<library name="http_auth" location="..\..\server\authentication\http_authorization\http_authorization-safe.ecf"/> <library name="http_auth" location="..\..\server\authentication\http_authorization\http_authorization-safe.ecf"/>
<library name="http_network" location="..\http_network\http_network-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/> <library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
<condition>
<custom name="ssl_enabled" value="true"/>
</condition>
<condition> <condition>
<custom name="netssl_http_client_enabled" value="true"/> <custom name="netssl_http_client_enabled" value="true"/>
</condition> </condition>
@@ -25,10 +29,14 @@
<cluster name="net_implementation" location="$|implementation\" hidden="true"/> <cluster name="net_implementation" location="$|implementation\" hidden="true"/>
<cluster name="net_ssl_disabled" location="$|no_ssl\"> <cluster name="net_ssl_disabled" location="$|no_ssl\">
<condition> <condition>
<custom name="ssl_enabled" excluded_value="true"/>
<custom name="netssl_http_client_enabled" excluded_value="true"/> <custom name="netssl_http_client_enabled" excluded_value="true"/>
</condition> </condition>
</cluster> </cluster>
<cluster name="net_ssl_enabled" location="$|ssl\"> <cluster name="net_ssl_enabled" location="$|ssl\">
<condition>
<custom name="ssl_enabled" value="true"/>
</condition>
<condition> <condition>
<custom name="netssl_http_client_enabled" value="true"/> <custom name="netssl_http_client_enabled" value="true"/>
</condition> </condition>

View File

@@ -13,8 +13,12 @@
<library name="encoder" location="..\..\text\encoder\encoder.ecf"/> <library name="encoder" location="..\..\text\encoder\encoder.ecf"/>
<library name="http" location="..\protocol\http\http.ecf"/> <library name="http" location="..\protocol\http\http.ecf"/>
<library name="http_auth" location="..\..\server\authentication\http_authorization\http_authorization.ecf"/> <library name="http_auth" location="..\..\server\authentication\http_authorization\http_authorization.ecf"/>
<library name="http_network" location="..\http_network\http_network.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/> <library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf">
<condition>
<custom name="ssl_enabled" value="true"/>
</condition>
<condition> <condition>
<custom name="netssl_http_client_enabled" value="true"/> <custom name="netssl_http_client_enabled" value="true"/>
</condition> </condition>
@@ -25,10 +29,14 @@
<cluster name="net_implementation" location="$|implementation\" hidden="true"/> <cluster name="net_implementation" location="$|implementation\" hidden="true"/>
<cluster name="net_ssl_disabled" location="$|no_ssl\"> <cluster name="net_ssl_disabled" location="$|no_ssl\">
<condition> <condition>
<custom name="ssl_enabled" excluded_value="true"/>
<custom name="netssl_http_client_enabled" excluded_value="true"/> <custom name="netssl_http_client_enabled" excluded_value="true"/>
</condition> </condition>
</cluster> </cluster>
<cluster name="net_ssl_enabled" location="$|ssl\"> <cluster name="net_ssl_enabled" location="$|ssl\">
<condition>
<custom name="ssl_enabled" value="true"/>
</condition>
<condition> <condition>
<custom name="netssl_http_client_enabled" value="true"/> <custom name="netssl_http_client_enabled" value="true"/>
</condition> </condition>

View File

@@ -11,7 +11,7 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (a_socket: NETWORK_STREAM_SOCKET; a_host: READABLE_STRING_GENERAL; a_port: INTEGER) make (a_socket: HTTP_STREAM_SOCKET; a_host: READABLE_STRING_GENERAL; a_port: INTEGER)
do do
socket := a_socket socket := a_socket
host := a_host host := a_host
@@ -20,7 +20,7 @@ feature {NONE} -- Initialization
feature -- Access feature -- Access
socket: NETWORK_STREAM_SOCKET socket: HTTP_STREAM_SOCKET
-- Persistent connection socket. -- Persistent connection socket.
host: READABLE_STRING_GENERAL host: READABLE_STRING_GENERAL
@@ -40,7 +40,7 @@ feature -- Status report
end end
note note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[ source: "[
Eiffel Software Eiffel Software

View File

@@ -28,11 +28,11 @@ feature {NONE} -- Internal
session: NET_HTTP_CLIENT_SESSION session: NET_HTTP_CLIENT_SESSION
net_http_client_version: STRING = "0.1" net_http_client_version: STRING = "0.1"
session_socket (a_host: READABLE_STRING_8; a_port: INTEGER; a_is_https: BOOLEAN; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): NETWORK_STREAM_SOCKET session_socket (a_host: READABLE_STRING_8; a_port: INTEGER; a_is_https: BOOLEAN; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_STREAM_SOCKET
-- Session socket to use for connection. -- Session socket to use for connection.
-- Eventually reuse the persistent connection if any. -- Eventually reuse the persistent connection if any.
local local
l_socket: detachable NETWORK_STREAM_SOCKET l_socket: detachable HTTP_STREAM_SOCKET
do do
if if
attached session.persistent_connection as l_persistent_connection and then attached session.persistent_connection as l_persistent_connection and then
@@ -40,12 +40,12 @@ feature {NONE} -- Internal
then then
l_socket := l_persistent_connection.socket l_socket := l_persistent_connection.socket
if a_is_https then if a_is_https then
if attached {SSL_NETWORK_STREAM_SOCKET} l_socket as l_ssl_socket then if attached {HTTP_STREAM_SSL_SOCKET} l_socket as l_ssl_socket then
Result := l_ssl_socket Result := l_ssl_socket
else else
l_socket := Void l_socket := Void
end end
elseif attached {SSL_NETWORK_STREAM_SOCKET} l_socket as l_ssl_socket then elseif attached {HTTP_STREAM_SSL_SOCKET} l_socket as l_ssl_socket then
l_socket := Void l_socket := Void
end end
if l_socket /= Void and then not l_socket.is_connected then if l_socket /= Void and then not l_socket.is_connected then
@@ -59,7 +59,7 @@ feature {NONE} -- Internal
else else
session.set_persistent_connection (Void) session.set_persistent_connection (Void)
if a_is_https then if a_is_https then
create {SSL_NETWORK_STREAM_SOCKET} Result.make_client_by_port (a_port, a_host) create {HTTP_STREAM_SSL_SOCKET} Result.make_client_by_port (a_port, a_host)
else else
create Result.make_client_by_port (a_port, a_host) create Result.make_client_by_port (a_port, a_host)
end end
@@ -81,7 +81,7 @@ feature -- Access
l_cookie: detachable READABLE_STRING_8 l_cookie: detachable READABLE_STRING_8
l_request_uri: STRING l_request_uri: STRING
l_url: HTTP_URL l_url: HTTP_URL
l_socket: NETWORK_STREAM_SOCKET l_socket: HTTP_STREAM_SOCKET
s: STRING s: STRING
l_message: STRING l_message: STRING
l_content_length: INTEGER l_content_length: INTEGER
@@ -438,7 +438,7 @@ feature {NONE} -- Helpers
io.error.put_string (m) io.error.put_string (m)
end end
is_ready_for_reading (a_socket: NETWORK_STREAM_SOCKET): BOOLEAN is_ready_for_reading (a_socket: HTTP_STREAM_SOCKET): BOOLEAN
-- Is `a_socket' ready for reading? -- Is `a_socket' ready for reading?
do do
Result := a_socket.ready_for_reading Result := a_socket.ready_for_reading
@@ -518,7 +518,7 @@ feature {NONE} -- Helpers
Result := utf.utf_32_string_to_utf_8_string_8 (s) Result := utf.utf_32_string_to_utf_8_string_8 (s)
end end
put_string_using_chunked_transfer_encoding (a_string: READABLE_STRING_8; a_chunk_size: INTEGER; a_output: NETWORK_STREAM_SOCKET) put_string_using_chunked_transfer_encoding (a_string: READABLE_STRING_8; a_chunk_size: INTEGER; a_output: HTTP_STREAM_SOCKET)
local local
i,n: INTEGER i,n: INTEGER
do do
@@ -534,7 +534,7 @@ feature {NONE} -- Helpers
put_chunk_end (Void, Void, a_output) put_chunk_end (Void, Void, a_output)
end end
put_chunk (a_content: READABLE_STRING_8; a_ext: detachable READABLE_STRING_8; a_output: NETWORK_STREAM_SOCKET) put_chunk (a_content: READABLE_STRING_8; a_ext: detachable READABLE_STRING_8; a_output: HTTP_STREAM_SOCKET)
-- Write chunk non empty `a_content' to `a_output' -- Write chunk non empty `a_content' to `a_output'
-- with optional extension `a_ext': chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) -- with optional extension `a_ext': chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
-- Note: that header "Transfer-Encoding: chunked" is required. -- Note: that header "Transfer-Encoding: chunked" is required.
@@ -569,7 +569,7 @@ feature {NONE} -- Helpers
a_output.put_string (crlf) a_output.put_string (crlf)
end end
put_chunk_end (a_ext: detachable READABLE_STRING_8; a_trailer: detachable READABLE_STRING_8; a_output: NETWORK_STREAM_SOCKET) put_chunk_end (a_ext: detachable READABLE_STRING_8; a_trailer: detachable READABLE_STRING_8; a_output: HTTP_STREAM_SOCKET)
-- Put end of chunked content, -- Put end of chunked content,
-- with optional extension `a_ext': chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) -- with optional extension `a_ext': chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
-- and with optional trailer `a_trailer' : trailer= *(entity-header CRLF) -- and with optional trailer `a_trailer' : trailer= *(entity-header CRLF)
@@ -595,7 +595,7 @@ feature {NONE} -- Helpers
a_output.put_string (crlf) a_output.put_string (crlf)
end end
append_file_content_to_socket_using_chunked_transfer_encoding (a_file: FILE; a_len: INTEGER; a_chunk_size: INTEGER; a_output: NETWORK_STREAM_SOCKET) append_file_content_to_socket_using_chunked_transfer_encoding (a_file: FILE; a_len: INTEGER; a_chunk_size: INTEGER; a_output: HTTP_STREAM_SOCKET)
-- Append `a_file' content as chunks of `a_chunk_size' length to `a_output'. -- Append `a_file' content as chunks of `a_chunk_size' length to `a_output'.
-- If `a_len' >= 0 then read only `a_len' characters. -- If `a_len' >= 0 then read only `a_len' characters.
require require
@@ -631,7 +631,7 @@ feature {NONE} -- Helpers
end end
end end
append_file_content_to_socket (a_file: FILE; a_len: INTEGER; a_output: NETWORK_STREAM_SOCKET) append_file_content_to_socket (a_file: FILE; a_len: INTEGER; a_output: HTTP_STREAM_SOCKET)
-- Append `a_file' content to `a_output'. -- Append `a_file' content to `a_output'.
-- If `a_len' >= 0 then read only `a_len' characters. -- If `a_len' >= 0 then read only `a_len' characters.
require require
@@ -704,7 +704,7 @@ feature {NONE} -- Helpers
end end
end end
append_socket_header_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: NETWORK_STREAM_SOCKET; a_output: STRING) append_socket_header_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: HTTP_STREAM_SOCKET; a_output: STRING)
-- Get header from `a_socket' into `a_output'. -- Get header from `a_socket' into `a_output'.
local local
s: READABLE_STRING_8 s: READABLE_STRING_8
@@ -714,7 +714,7 @@ feature {NONE} -- Helpers
until until
s.same_string ("%R") or not a_socket.readable or a_response.error_occurred s.same_string ("%R") or not a_socket.readable or a_response.error_occurred
loop loop
a_socket.read_line_thread_aware a_socket.read_line_noexception
s := a_socket.last_string s := a_socket.last_string
if s.is_empty then if s.is_empty then
if session.is_debug_verbose then if session.is_debug_verbose then
@@ -730,7 +730,7 @@ feature {NONE} -- Helpers
end end
end end
append_socket_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: NETWORK_STREAM_SOCKET; a_len: INTEGER; a_output: STRING) append_socket_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: HTTP_STREAM_SOCKET; a_len: INTEGER; a_output: STRING)
-- Get content from `a_socket' and append it to `a_output'. -- Get content from `a_socket' and append it to `a_output'.
-- If `a_len' is negative, try to get as much as possible, -- If `a_len' is negative, try to get as much as possible,
-- this is probably HTTP/1.0 without any Content-Length. -- this is probably HTTP/1.0 without any Content-Length.
@@ -749,7 +749,7 @@ feature {NONE} -- Helpers
until until
r = 0 or else not a_socket.readable or else a_response.error_occurred r = 0 or else not a_socket.readable or else a_response.error_occurred
loop loop
a_socket.read_stream_thread_aware (r) a_socket.read_stream_noexception (r)
l_count := l_count + a_socket.bytes_read l_count := l_count + a_socket.bytes_read
if session.is_debug_verbose then if session.is_debug_verbose then
log ("Debug: - byte read=" + a_socket.bytes_read.out + "%N") log ("Debug: - byte read=" + a_socket.bytes_read.out + "%N")
@@ -772,7 +772,7 @@ feature {NONE} -- Helpers
until until
n < l_chunk_size or not a_socket.readable n < l_chunk_size or not a_socket.readable
loop loop
a_socket.read_stream_thread_aware (l_chunk_size) a_socket.read_stream_noexception (l_chunk_size)
s := a_socket.last_string s := a_socket.last_string
n := a_socket.bytes_read n := a_socket.bytes_read
l_count := l_count + n l_count := l_count + n
@@ -782,7 +782,7 @@ feature {NONE} -- Helpers
end end
end end
append_socket_chunked_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: NETWORK_STREAM_SOCKET; a_output: STRING) append_socket_chunked_content_to (a_response: HTTP_CLIENT_RESPONSE; a_socket: HTTP_STREAM_SOCKET; a_output: STRING)
-- Get chunked content from `a_socket' and append it to `a_output'. -- Get chunked content from `a_socket' and append it to `a_output'.
require require
socket_readable: a_socket.readable socket_readable: a_socket.readable
@@ -803,7 +803,7 @@ feature {NONE} -- Helpers
until until
n = 0 or not a_socket.readable n = 0 or not a_socket.readable
loop loop
a_socket.read_line_thread_aware -- Read chunk info a_socket.read_line_noexception
s := a_socket.last_string s := a_socket.last_string
s.right_adjust s.right_adjust
if session.is_debug_verbose then if session.is_debug_verbose then
@@ -832,7 +832,7 @@ feature {NONE} -- Helpers
until until
r = 0 or else not a_socket.readable or else a_response.error_occurred r = 0 or else not a_socket.readable or else a_response.error_occurred
loop loop
a_socket.read_stream_thread_aware (r) a_socket.read_stream_noexception (r)
l_count := l_count + a_socket.bytes_read l_count := l_count + a_socket.bytes_read
if session.is_debug_verbose then if session.is_debug_verbose then
log ("Debug: - byte read=" + a_socket.bytes_read.out + "%N") log ("Debug: - byte read=" + a_socket.bytes_read.out + "%N")
@@ -842,9 +842,9 @@ feature {NONE} -- Helpers
a_output.append (a_socket.last_string) a_output.append (a_socket.last_string)
end end
a_socket.read_character a_socket.read_character_noexception
check a_socket.last_character = '%R' end check a_socket.last_character = '%R' end
a_socket.read_character a_socket.read_character_noexception
check a_socket.last_character = '%N' end check a_socket.last_character = '%N' end
if session.is_debug_verbose then if session.is_debug_verbose then
log ("Debug: - Found CRNL %N") log ("Debug: - Found CRNL %N")

View File

@@ -1,22 +0,0 @@
note
description: "[
A fake SSL network stream socket... when SSL is disabled at compilation time.
Its behavior is similar to NETWORK_STREAM_SOCKET.
]"
date: "$Date$"
revision: "$Revision$"
class
SSL_NETWORK_STREAM_SOCKET
inherit
NETWORK_STREAM_SOCKET
create
make, make_empty, make_client_by_port, make_client_by_address_and_port, make_server_by_port, make_loopback_server_by_port
create {SSL_NETWORK_STREAM_SOCKET}
make_from_descriptor_and_address, create_from_descriptor
end

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="http_network" uuid="56DAA1CE-0A2E-451A-BFC9-7821578E79F0" library_target="http_network"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="http_network" uuid="7C7AD84D-B7BD-4709-B4B2-9365B86582AE" library_target="http_network">
<target name="http_network"> <target name="http_network">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
@@ -11,6 +11,16 @@
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option> </option>
<setting name="concurrency" value="scoop"/> <setting name="concurrency" value="scoop"/>
<external_include location="$ECF_CONFIG_PATH/spec/include">
<condition>
<version type="compiler" min="16.11.0.0"/>
</condition>
</external_include>
<external_include location="$ECF_CONFIG_PATH/spec/include_until_16_05">
<condition>
<version type="compiler" max="16.11.0.0"/>
</condition>
</external_include>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf" readonly="false"/> <library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf" readonly="false"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
@@ -24,13 +34,20 @@
<custom name="httpd_ssl_enabled" value="true"/> <custom name="httpd_ssl_enabled" value="true"/>
</condition> </condition>
</library> </library>
<cluster name="network" location=".\network\"> <cluster name="network" location=".\src\">
<file_rule> <file_rule>
<exclude>/httpd_stream_socket_ext.e$</exclude> <exclude>/httpd_stream_socket_ext.e$</exclude>
<condition> <condition>
<version type="compiler" max="16.11.0.0"/> <version type="compiler" max="16.11.0.0"/>
</condition> </condition>
</file_rule> </file_rule>
<cluster name="disabled_ssl_network" location="$|no_ssl\" recursive="true">
<condition>
<custom name="ssl_enabled" excluded_value="true"/>
<custom name="net_ssl_enabled" excluded_value="true"/>
<custom name="httpd_ssl_enabled" excluded_value="true"/>
</condition>
</cluster>
<cluster name="ssl_network" location="$|ssl\" recursive="true"> <cluster name="ssl_network" location="$|ssl\" recursive="true">
<condition> <condition>
<custom name="ssl_enabled" value="true"/> <custom name="ssl_enabled" value="true"/>
@@ -58,7 +75,7 @@
</file_rule> </file_rule>
</cluster> </cluster>
</cluster> </cluster>
<cluster name="network_until_16_05" location=".\network\until_16_05\" recursive="false"> <cluster name="network_until_16_05" location=".\src\until_16_05\" recursive="false">
<condition> <condition>
<version type="compiler" max="16.11.0.0"/> <version type="compiler" max="16.11.0.0"/>
</condition> </condition>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="http_network" uuid="56DAA1CE-0A2E-451A-BFC9-7821578E79F0" library_target="http_network"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="http_network" uuid="7C7AD84D-B7BD-4709-B4B2-9365B86582AE" library_target="http_network">
<target name="http_network"> <target name="http_network">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
@@ -11,6 +11,16 @@
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option> </option>
<setting name="concurrency" value="scoop"/> <setting name="concurrency" value="scoop"/>
<external_include location="$ECF_CONFIG_PATH/spec/include">
<condition>
<version type="compiler" min="16.11.0.0"/>
</condition>
</external_include>
<external_include location="$ECF_CONFIG_PATH/spec/include_until_16_05">
<condition>
<version type="compiler" max="16.11.0.0"/>
</condition>
</external_include>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/> <library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf">
@@ -24,7 +34,7 @@
<custom name="httpd_ssl_enabled" value="true"/> <custom name="httpd_ssl_enabled" value="true"/>
</condition> </condition>
</library> </library>
<cluster name="network" location=".\network\"> <cluster name="network" location=".\src\">
<file_rule> <file_rule>
<exclude>/httpd_stream_socket_ext.e$</exclude> <exclude>/httpd_stream_socket_ext.e$</exclude>
<condition> <condition>
@@ -58,7 +68,7 @@
</file_rule> </file_rule>
</cluster> </cluster>
</cluster> </cluster>
<cluster name="network_until_16_05" location=".\network\until_16_05\" recursive="false"> <cluster name="network_until_16_05" location=".\src\until_16_05\" recursive="false">
<condition> <condition>
<version type="compiler" max="16.11.0.0"/> <version type="compiler" max="16.11.0.0"/>
</condition> </condition>

View File

@@ -0,0 +1,10 @@
${NOTE_KEYWORD}
copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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
]"

View File

@@ -1,15 +1,15 @@
note note
description: "Summary description for {HTTPD_STREAM_SOCKET}." description: "Summary description for {HTTP_STREAM_SOCKET}."
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
class class
HTTPD_STREAM_SOCKET HTTP_STREAM_SOCKET
inherit inherit
NETWORK_STREAM_SOCKET NETWORK_STREAM_SOCKET
HTTPD_STREAM_SOCKET_EXT HTTP_STREAM_SOCKET_EXT
create create
make, make_empty, make, make_empty,
@@ -230,7 +230,7 @@ feature -- Status report
end end
note note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[ source: "[
Eiffel Software Eiffel Software

View File

@@ -6,7 +6,7 @@ note
]" ]"
deferred class deferred class
HTTPD_STREAM_SOCKET_EXT HTTP_STREAM_SOCKET_EXT
feature {NONE} -- No-Exception network operation feature {NONE} -- No-Exception network operation

View File

@@ -0,0 +1,27 @@
note
description: "[
A fake SSL network stream socket... when SSL is disabled at compilation time.
Its behavior is similar to HTTP_STREAM_SOCKET.
]"
date: "$Date$"
revision: "$Revision$"
class
HTTP_STREAM_SSL_SOCKET
inherit
HTTP_STREAM_SOCKET
create
make, make_empty,
make_client_by_port, make_client_by_address_and_port,
make_server_by_port, make_server_by_address_and_port, make_loopback_server_by_port
create {HTTP_STREAM_SSL_SOCKET}
make_from_descriptor_and_address
note
copyright: "2011-2013, Javier Velilla, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -4,10 +4,10 @@ note
revision: "$Revision$" revision: "$Revision$"
class class
HTTPD_STREAM_SSL_SOCKET HTTP_STREAM_SSL_SOCKET
inherit inherit
HTTPD_STREAM_SOCKET HTTP_STREAM_SOCKET
undefine undefine
make_empty, make_from_descriptor_and_address, make_empty, make_from_descriptor_and_address,
error_number, error_number,
@@ -31,7 +31,7 @@ inherit
put_managed_pointer -- Redefine to allow support of compiler before 16.11. put_managed_pointer -- Redefine to allow support of compiler before 16.11.
end end
HTTPD_STREAM_SSL_SOCKET_EXT HTTP_STREAM_SSL_SOCKET_EXT
create create
make, make_empty, make, make_empty,
@@ -105,7 +105,7 @@ feature -- Output
-- Put data of length `nb_bytes' pointed by `start_pos' index in `p' at -- Put data of length `nb_bytes' pointed by `start_pos' index in `p' at
-- current position. -- current position.
do do
Precursor {HTTPD_STREAM_SOCKET} (p, start_pos, nb_bytes) Precursor {HTTP_STREAM_SOCKET} (p, start_pos, nb_bytes)
end end
put_pointer_content_noexception (a_pointer: POINTER; a_offset, a_byte_count: INTEGER) put_pointer_content_noexception (a_pointer: POINTER; a_offset, a_byte_count: INTEGER)

View File

@@ -1,12 +1,12 @@
note note
description: "[ description: "[
Extension to HTTPD_STREAM_SOCKET to support backward compatibility. Extension to HTTP_STREAM_SOCKET to support backward compatibility.
TO BE REMOVED IN THE FUTURE, WHEN 16.05 IS OLD. TO BE REMOVED IN THE FUTURE, WHEN 16.05 IS OLD.
]" ]"
deferred class deferred class
HTTPD_STREAM_SSL_SOCKET_EXT HTTP_STREAM_SSL_SOCKET_EXT
feature {NONE} -- SSL bridge feature {NONE} -- SSL bridge

View File

@@ -9,7 +9,7 @@ note
]" ]"
deferred class deferred class
HTTPD_STREAM_SOCKET_EXT HTTP_STREAM_SOCKET_EXT
inherit inherit
PLATFORM PLATFORM

View File

@@ -1,12 +1,12 @@
note note
description: "[ description: "[
Extension to HTTPD_STREAM_SOCKET to support backward compatibility. Extension to HTTP_STREAM_SOCKET to support backward compatibility.
TO BE REMOVED IN THE FUTURE, WHEN 16.05 IS OLD. TO BE REMOVED IN THE FUTURE, WHEN 16.05 IS OLD.
]" ]"
deferred class deferred class
HTTPD_STREAM_SSL_SOCKET_EXT HTTP_STREAM_SSL_SOCKET_EXT
feature {NONE} -- SSL bridge feature {NONE} -- SSL bridge

View File

@@ -16,7 +16,7 @@
<library name="encoder" location="..\..\..\..\text\encoder\encoder-safe.ecf"/> <library name="encoder" location="..\..\..\..\text\encoder\encoder-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/> <library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\network\protocol\http\http-safe.ecf"/> <library name="http" location="..\..\..\..\network\protocol\http\http-safe.ecf"/>
<library name="http_network" location="..\..\..\httpd\http_network-safe.ecf" readonly="false"/> <library name="http_network" location="..\..\..\..\network\http_network\http_network-safe.ecf" readonly="false"/>
<library name="httpd" location="..\..\..\httpd\httpd-safe.ecf" readonly="false"/> <library name="httpd" location="..\..\..\httpd\httpd-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\"> <cluster name="src" location=".\src\">
<cluster name="implementation" location="$|implementation\" hidden="true"/> <cluster name="implementation" location="$|implementation\" hidden="true"/>

View File

@@ -15,7 +15,7 @@
<library name="encoder" location="..\..\..\..\text\encoder\encoder.ecf"/> <library name="encoder" location="..\..\..\..\text\encoder\encoder.ecf"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/> <library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\network\protocol\http\http.ecf"/> <library name="http" location="..\..\..\..\network\protocol\http\http.ecf"/>
<library name="http_network" location="..\..\..\httpd\http_network.ecf" readonly="false"/> <library name="http_network" location="..\..\..\..\network\http_network\http_network.ecf" readonly="false"/>
<library name="httpd" location="..\..\..\httpd\httpd.ecf" readonly="false"/> <library name="httpd" location="..\..\..\httpd\httpd.ecf" readonly="false"/>
<cluster name="src" location=".\src\"> <cluster name="src" location=".\src\">
<cluster name="implementation" location="$|implementation\" hidden="true"/> <cluster name="implementation" location="$|implementation\" hidden="true"/>

View File

@@ -33,9 +33,9 @@ feature -- Access
feature {HTTPD_SERVER_I} -- Execution feature {HTTPD_SERVER_I} -- Execution
accept_incoming_connection (a_listening_socket: HTTPD_STREAM_SOCKET) accept_incoming_connection (a_listening_socket: HTTP_STREAM_SOCKET)
local local
cl: HTTPD_STREAM_SOCKET cl: HTTP_STREAM_SOCKET
do do
is_shutdown_requested := is_shutdown_requested or shutdown_requested (server) is_shutdown_requested := is_shutdown_requested or shutdown_requested (server)
if is_shutdown_requested then if is_shutdown_requested then

View File

@@ -64,19 +64,19 @@ feature {HTTPD_SERVER_I} -- Execution
p.gracefull_stop p.gracefull_stop
end end
accept_incoming_connection (a_listening_socket: HTTPD_STREAM_SOCKET) accept_incoming_connection (a_listening_socket: HTTP_STREAM_SOCKET)
-- <Precursor> -- <Precursor>
do do
accept_connection_on_pool (pool, a_listening_socket) -- Wait on not pool.is_full or is_stop_requested accept_connection_on_pool (pool, a_listening_socket) -- Wait on not pool.is_full or is_stop_requested
end end
accept_connection_on_pool (a_pool: like pool; a_listening_socket: HTTPD_STREAM_SOCKET) accept_connection_on_pool (a_pool: like pool; a_listening_socket: HTTP_STREAM_SOCKET)
-- Process accept connection -- Process accept connection
-- note that the precondition matters for scoop synchronization. -- note that the precondition matters for scoop synchronization.
require require
concurrency: not a_pool.is_full or is_shutdown_requested or a_pool.stop_requested concurrency: not a_pool.is_full or is_shutdown_requested or a_pool.stop_requested
local local
cl: separate HTTPD_STREAM_SOCKET cl: separate HTTP_STREAM_SOCKET
do do
debug ("dbglog") debug ("dbglog")
dbglog (generator + ".ENTER accept_connection_on_pool") dbglog (generator + ".ENTER accept_connection_on_pool")
@@ -121,7 +121,7 @@ feature {HTTPD_SERVER_I} -- Status report
feature {NONE} -- Implementation feature {NONE} -- Implementation
separate_client_socket (hdl: separate HTTPD_REQUEST_HANDLER): separate HTTPD_STREAM_SOCKET separate_client_socket (hdl: separate HTTPD_REQUEST_HANDLER): separate HTTP_STREAM_SOCKET
-- Client socket for request handler `hdl'. -- Client socket for request handler `hdl'.
do do
Result := hdl.client_socket Result := hdl.client_socket

View File

@@ -51,9 +51,9 @@ feature {HTTPD_SERVER_I} -- Execution
p.terminate p.terminate
end end
accept_incoming_connection (a_listening_socket: HTTPD_STREAM_SOCKET) accept_incoming_connection (a_listening_socket: HTTP_STREAM_SOCKET)
local local
cl: separate HTTPD_STREAM_SOCKET cl: separate HTTP_STREAM_SOCKET
do do
debug ("dbglog") debug ("dbglog")
dbglog (generator + ".ENTER accept_connection {"+ a_listening_socket.descriptor.out +"}") dbglog (generator + ".ENTER accept_connection {"+ a_listening_socket.descriptor.out +"}")

View File

@@ -11,18 +11,8 @@
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option> </option>
<setting name="concurrency" value="scoop"/> <setting name="concurrency" value="scoop"/>
<external_include location="$ECF_CONFIG_PATH/spec/include">
<condition>
<version type="compiler" min="16.11.0.0"/>
</condition>
</external_include>
<external_include location="$ECF_CONFIG_PATH/spec/include_until_16_05">
<condition>
<version type="compiler" max="16.11.0.0"/>
</condition>
</external_include>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="http_network" location="http_network-safe.ecf" readonly="false"/> <library name="http_network" location="..\..\network\http_network\http_network-safe.ecf" readonly="false"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/> <library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
<condition> <condition>

View File

@@ -11,7 +11,7 @@
</option> </option>
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="http_network" location="http_network.ecf" readonly="false"/> <library name="http_network" location="..\..\network\http_network\http_network.ecf" readonly="false"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/> <library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf"> <library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf">
<condition> <condition>

View File

@@ -39,7 +39,7 @@ feature {NONE} -- Access
feature {HTTPD_SERVER_I} -- Execution feature {HTTPD_SERVER_I} -- Execution
accept_incoming_connection (a_listening_socket: HTTPD_STREAM_SOCKET) accept_incoming_connection (a_listening_socket: HTTP_STREAM_SOCKET)
-- Accept incoming connection from `a_listening_socket'. -- Accept incoming connection from `a_listening_socket'.
deferred deferred
end end

View File

@@ -72,9 +72,9 @@ feature -- Status report
feature -- Access feature -- Access
internal_client_socket: detachable HTTPD_STREAM_SOCKET internal_client_socket: detachable HTTP_STREAM_SOCKET
client_socket: HTTPD_STREAM_SOCKET client_socket: HTTP_STREAM_SOCKET
local local
s: like internal_client_socket s: like internal_client_socket
do do
@@ -331,7 +331,7 @@ feature -- Execution
feature -- Request processing feature -- Request processing
process_request (a_socket: HTTPD_STREAM_SOCKET) process_request (a_socket: HTTP_STREAM_SOCKET)
-- Process request on socket `a_socket'. -- Process request on socket `a_socket'.
require require
no_error: not has_error no_error: not has_error
@@ -343,7 +343,7 @@ feature -- Request processing
deferred deferred
end end
process_bad_request (a_socket: HTTPD_STREAM_SOCKET) process_bad_request (a_socket: HTTP_STREAM_SOCKET)
-- Process bad request catched on `a_socket'. -- Process bad request catched on `a_socket'.
require require
has_error: has_error has_error: has_error
@@ -378,7 +378,7 @@ feature -- Request processing
feature -- Parsing feature -- Parsing
get_request_header (a_socket: HTTPD_STREAM_SOCKET; a_is_reusing_connection: BOOLEAN) get_request_header (a_socket: HTTP_STREAM_SOCKET; a_is_reusing_connection: BOOLEAN)
-- Analyze message extracted from `a_socket' as HTTP request. -- Analyze message extracted from `a_socket' as HTTP request.
-- If `a_is_reusing_connection' is True, then first use -- If `a_is_reusing_connection' is True, then first use
-- Note: it reads from socket. -- Note: it reads from socket.
@@ -504,7 +504,7 @@ feature -- Parsing
end end
end end
next_line (a_socket: HTTPD_STREAM_SOCKET): detachable STRING next_line (a_socket: HTTP_STREAM_SOCKET): detachable STRING
-- Next line fetched from `a_socket' is available. -- Next line fetched from `a_socket' is available.
-- note: may update `has_error'. -- note: may update `has_error'.
require require
@@ -569,7 +569,7 @@ feature -- Output
feature {NONE} -- Helpers feature {NONE} -- Helpers
socket_has_incoming_data (a_socket: HTTPD_STREAM_SOCKET): BOOLEAN socket_has_incoming_data (a_socket: HTTP_STREAM_SOCKET): BOOLEAN
-- Is there any data to read on `a_socket' ? -- Is there any data to read on `a_socket' ?
require require
a_socket.readable a_socket.readable

View File

@@ -151,7 +151,7 @@ feature -- Listening
-- Creates a socket and connects to the http server. -- Creates a socket and connects to the http server.
-- `a_server': The main server object -- `a_server': The main server object
local local
l_listening_socket: detachable HTTPD_STREAM_SOCKET l_listening_socket: detachable HTTP_STREAM_SOCKET
l_http_port: INTEGER l_http_port: INTEGER
l_connection_handler: HTTPD_CONNECTION_HANDLER l_connection_handler: HTTPD_CONNECTION_HANDLER
do do
@@ -234,7 +234,7 @@ feature -- Listening
feature {NONE} -- Factory feature {NONE} -- Factory
new_listening_socket (a_addr: detachable INET_ADDRESS; a_http_port: INTEGER): HTTPD_STREAM_SOCKET new_listening_socket (a_addr: detachable INET_ADDRESS; a_http_port: INTEGER): HTTP_STREAM_SOCKET
do do
if a_addr /= Void then if a_addr /= Void then
create Result.make_server_by_address_and_port (a_addr, a_http_port) create Result.make_server_by_address_and_port (a_addr, a_http_port)

View File

@@ -0,0 +1,10 @@
${NOTE_KEYWORD}
copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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
]"

View File

@@ -8,7 +8,7 @@ deferred class
feature -- Access feature -- Access
new_client_socket (a_is_secure: BOOLEAN): HTTPD_STREAM_SOCKET new_client_socket (a_is_secure: BOOLEAN): HTTP_STREAM_SOCKET
do do
check not_secure: not a_is_secure end check not_secure: not a_is_secure end
create Result.make_empty create Result.make_empty

View File

@@ -19,7 +19,7 @@ create
feature {NONE} -- Factory feature {NONE} -- Factory
new_listening_socket (a_addr: detachable INET_ADDRESS; a_http_port: INTEGER): HTTPD_STREAM_SOCKET new_listening_socket (a_addr: detachable INET_ADDRESS; a_http_port: INTEGER): HTTP_STREAM_SOCKET
local local
s_ssl: HTTPD_STREAM_SSL_SOCKET s_ssl: HTTPD_STREAM_SSL_SOCKET
do do

View File

@@ -8,7 +8,7 @@ deferred class
feature -- Access feature -- Access
new_client_socket (a_is_secure: BOOLEAN): HTTPD_STREAM_SOCKET new_client_socket (a_is_secure: BOOLEAN): HTTP_STREAM_SOCKET
do do
if a_is_secure then if a_is_secure then
create {HTTPD_STREAM_SSL_SOCKET} Result.make_empty create {HTTPD_STREAM_SSL_SOCKET} Result.make_empty