From 6153ba7599f2ce1ab22959a40b6ca33b4238f0d0 Mon Sep 17 00:00:00 2001
From: Micael Karlberg Sends an arbitrary FTP command and returns verbatimly a list
diff --git a/lib/inets/doc/src/http.xml b/lib/inets/doc/src/http.xml
deleted file mode 100644
index f6f8338113..0000000000
--- a/lib/inets/doc/src/http.xml
+++ /dev/null
@@ -1,491 +0,0 @@
-
-
-
- This module provides the API to a HTTP/1.1 client according to
- RFC 2616, caching is currently not supported. When starting the Inets application a manager process for the
- default profile will be started. The functions in this API
- that does not explicitly use a profile will accesses the
- default profile. A profile keeps track of proxy options,
- cookies and other options that can be applied to more than one
- request. If the scheme
- https is used the ssl application needs to be started. Also note that pipelining will only be used if the pipeline
- timeout is set, otherwise persistent connections without
- pipelining will be used e.i. the client always waits for
- the previous response before sending the next request. There are some usage examples in the Type definitions that are used more than once in
- this module: Type definitions that are related to HTTP: For more information about HTTP see rfc 2616 Some type definitions relevant when using https,
- for details A HTTP client can be configured to start when starting the inets
- application or started dynamically in runtime by calling the
- inets application API The client can be stopped using inets:stop(httpc, Pid) or
- inets:stop(httpc, Profile). Cancels an asynchronous HTTP-request. Equivalent to http:request(get, {Url, []}, [], []). Sends a HTTP-request. The function can be both synchronous
- and asynchronous. In the later case the function will return
- {ok, RequestId} and later on message(s) will be sent to the
- calling process on the format: Http option ( Timeout time for the request. Defaults to Connection timeout time, used during the initial request,
- when the client is connecting to the server. Defaults to the value of the If using SSL, these SSL-specific options are used. Defaults to Should the client automatically retreive the information
- from the new URI and return that as the result instead
- of a 30X-result code. Note that for some 30X-result codes automatic redirect
- is not allowed in these cases the 30X-result will always
- be returned. Defaults to A proxy-authorization header using the provided user name and
- password will be added to the request. Can be used to make the client act as an Defaults to the trsing If set to true workarounds for known server deviations from
- the HTTP-standard are enabled. Defaults to Option ( Shall the request be synchronous or asynchronous. Defaults to Streams the body of a 200 or 206 response to the calling
- process or to a file. When streaming to the calling process
- using the option Note that it is possible that chunked encoding will add
- headers so that there are more headers in the stream_end
- message than in the stream_start.
- When streaming to a file and the request is asynchronous the
- message {http, {RequestId, saved_to_file}} will be sent. Defaults to Defines if the body shall be delivered as a string or as a
- binary. This option is only valid for the synchronous
- request. Defaults to Should a "full result" be returned to the caller (that is,
- the body, the headers and the entire status-line) or not
- (the body and the status code). Defaults to Shall the headers provided by the user be made
- lower case or be regarded as case sensitive. Note that the http standard requires them to be
- case insenstive. This feature should only be used if there is
- no other way to communicate with the server or for testing
- purpose. Also note that when this option is used no headers
- will be automatically added, all necessary headers has to be
- provided by the user. Defaults to Sets options to be used for subsequent
- requests. If possible the client will keep its connections
- alive and use persistent connections
- with or without pipeline depending on configuration
- and current circumstances. The HTTP/1.1 specification does not
- provide a guideline for how many requests that would be
- ideal to be sent on a persistent connection,
- this very much depends on the
- application. Note that a very long queue of requests may cause a
- user perceived delays as earlier request may take a long time
- to complete. The HTTP/1.1 specification does suggest a
- limit of 2 persistent connections per server, which is the
- default value of the max_sessions option. Triggers the next message to be streamed, e.i.
- same behavior as active once for sockets. Saves the cookies defined in SetCookieHeaders
- in the client profile's cookie database. You need to
- call this function if you set the option cookies to verify.
- If no profile is specified the default profile will be used.
- Returns the cookie header that would be sent
- when making a request to Url using the profile Profile.
- If no profile is specified the default profile will be used.
- RFC 2616, The server is configured using an erlang property list.
For the available properties see
-
-
-
-
-
-
- {http, {RequestId, Result}}
- {http, {RequestId, {error, Reason}}}
- {http, {RequestId, stream_start, Headers}
- {http, {RequestId, stream, BinBodyPart}
- {http, {RequestId, stream_end, Headers}
- {http, {RequestId, saved_to_file}}.
-
-
-
-\011 GroupName: Member1 Member2 .... MemberN
+GroupName: Member1 Member2 .... MemberN
-\011 UserName:Password -\011 UserName:Password +UserName:Password +UserName:Password
-\011 <Limit POST GET HEAD> -\011 order allow deny -\011 require group group1 -\011 allow from 123.145.244.5 -\011 </Limit> +<Limit POST GET HEAD> + order allow deny + require group group1 + allow from 123.145.244.5 +</Limit>
-"Content-Type:text/plain\
-Accept-Ranges:none\
-\
-some very
-\011plain text"
+
+ "Content-Type:text/plain\nAccept-Ranges:none\n\nsome very
+ plain text"
+
The server will interpret the cgi-headers and most of them will be transformed into HTTP headers and sent back to the client together with the body.
@@ -387,7 +385,7 @@ some very the extra overhead. An URL which calls an Erlang erl function has the following syntax (regular expression):
-\011 http://your.server.org/***/Module[:/]Function(?QueryString|/PathInfo)
+http://your.server.org/***/Module[:/]Function(?QueryString|/PathInfo)
*** above depends on how the ErlScriptAlias config directive has been used
@@ -428,7 +426,7 @@ http://your.server.org/***/Mod:Func(Arg1,...,ArgN) http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[])))which effectively will close down the Erlang node, - that is use the erl scheme instead, until this + therefor, use the erl scheme instead, until this security breach has been fixed.
Today there are no good way of solving this problem and therefore Eval Scheme may be removed in future @@ -498,14 +496,14 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ for parsed files, for example:
-\011text/x-server-parsed-html shtml shtm + text/x-server-parsed-html shtml shtm
This makes files ending with
-\011text/x-server-parsed-html html htm + text/x-server-parsed-html html htm@@ -518,7 +516,7 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ unparsed. Each directive has the following format:
-\011<!--#command tag1="value1" tag2="value2" --> + <!--#command tag1="value1" tag2="value2" -->
Each command takes different arguments, most only accept one
tag at a time. Here is a breakdown of the commands and their
@@ -612,7 +610,7 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[
The unescaped version of any search query the client
sent, with all shell-special characters escaped with
-
- -module(mnesia_test).
- -export([start/0,load_data/0]).
- -include("mod_auth.hrl").
-
- first_start()->
- mnesia:create_schema([node()]),
- mnesia:start(),
- mnesia:create_table(httpd_user,
- [{type,bag},{disc_copies,[node()]},
- {attributes,record_info(fields,httpd_user)}]),
- mnesia:create_table(httpd_group,
- [{type,bag},{disc_copies,[node()]},
- {attributes,record_info(fields,httpd_group)}]),
- mnesia:wait_for_tables([httpd_user,httpd_group],60000).
-
- start()->
- mnesia:start(),
- mnesia:wait_for_tables([httpd_user,httpd_group],60000).
+-module(mnesia_test).
+-export([start/0,load_data/0]).
+-include("mod_auth.hrl").
+
+first_start() ->
+ mnesia:create_schema([node()]),
+ mnesia:start(),
+ mnesia:create_table(httpd_user,
+ [{type, bag},
+ {disc_copies, [node()]},
+ {attributes, record_info(fields,
+ httpd_user)}]),
+ mnesia:create_table(httpd_group,
+ [{type, bag},
+ {disc_copies, [node()]},
+ {attributes, record_info(fields,
+ httpd_group)}]),
+ mnesia:wait_for_tables([httpd_user, httpd_group], 60000).
+
+start() ->
+ mnesia:start(),
+ mnesia:wait_for_tables([httpd_user, httpd_group], 60000).
To create the Mnesia tables we use two records defined in
diff --git a/lib/inets/doc/src/httpc.xml b/lib/inets/doc/src/httpc.xml
new file mode 100644
index 0000000000..680473cc38
--- /dev/null
+++ b/lib/inets/doc/src/httpc.xml
@@ -0,0 +1,581 @@
+
+
+
+ This module provides the API to a HTTP/1.1 compatible client according
+ to RFC 2616, caching is currently not supported. When starting the Inets application a manager process for the
+ default profile will be started. The functions in this API
+ that does not explicitly use a profile will accesses the
+ default profile. A profile keeps track of proxy options,
+ cookies and other options that can be applied to more than one
+ request. If the scheme
+ https is used the ssl application needs to be started. Also note that pipelining will only be used if the pipeline
+ timeout is set, otherwise persistent connections without
+ pipelining will be used e.i. the client always waits for
+ the previous response before sending the next request. There are some usage examples in the Type definitions that are used more than once in
+ this module: Type definitions that are related to HTTP: For more information about HTTP see rfc 2616 Some type definitions relevant when using https,
+ for details A HTTP client can be configured to start when starting the inets
+ application or started dynamically in runtime by calling the
+ inets application API The client can be stopped using inets:stop(httpc, Pid) or
+ inets:stop(httpc, Profile). Equivalent to httpc:request(get, {Url, []}, [], []). Sends a HTTP-request. The function can be both synchronous
+ and asynchronous. In the later case the function will return
+ {ok, RequestId} and later on the information will be delivered
+ to the Http option ( Timeout time for the request. The clock start ticking as soon as the request has been
+ sent. Time is in milliseconds. Defaults to Connection timeout time, used during the initial request,
+ when the client is connecting to the server. Time is in milliseconds. Defaults to the value of the If using SSL, these SSL-specific options are used. Defaults to Should the client automatically retreive the information
+ from the new URI and return that as the result instead
+ of a 30X-result code. Note that for some 30X-result codes automatic redirect
+ is not allowed in these cases the 30X-result will always
+ be returned. Defaults to A proxy-authorization header using the provided user name and
+ password will be added to the request. Can be used to make the client act as an Defaults to the trsing If set to true workarounds for known server deviations from
+ the HTTP-standard are enabled. Defaults to Option ( Shall the request be synchronous or asynchronous. Defaults to Streams the body of a 200 or 206 response to the calling
+ process or to a file. When streaming to the calling process
+ using the option Note that it is possible that chunked encoding will add
+ headers so that there are more headers in the stream_end
+ message than in the stream_start.
+ When streaming to a file and the request is asynchronous the
+ message {http, {RequestId, saved_to_file}} will be sent. Defaults to Defines if the body shall be delivered as a string or as a
+ binary. This option is only valid for the synchronous
+ request. Defaults to Should a "full result" be returned to the caller (that is,
+ the body, the headers and the entire status-line) or not
+ (the body and the status code). Defaults to Shall the headers provided by the user be made
+ lower case or be regarded as case sensitive. Note that the http standard requires them to be
+ case insenstive. This feature should only be used if there is
+ no other way to communicate with the server or for testing
+ purpose. Also note that when this option is used no headers
+ will be automatically added, all necessary headers has to be
+ provided by the user. Defaults to Defines how the client will deliver the result for a
+ asynchroneous request ( Message(s) will be sent to this process in the format: Information will be delivered to the receiver via calls
+ to the provided fun: Information will be delivered to the receiver via calls
+ to the callback function: In all cases above, Defaults to the Cancels an asynchronous HTTP-request. Sets options to be used for subsequent
+ requests. If possible the client will keep its connections
+ alive and use persistent connections
+ with or without pipeline depending on configuration
+ and current circumstances. The HTTP/1.1 specification does not
+ provide a guideline for how many requests that would be
+ ideal to be sent on a persistent connection,
+ this very much depends on the
+ application. Note that a very long queue of requests may cause a
+ user perceived delays as earlier request may take a long time
+ to complete. The HTTP/1.1 specification does suggest a
+ limit of 2 persistent connections per server, which is the
+ default value of the max_sessions option. Triggers the next message to be streamed, e.i.
+ same behavior as active once for sockets. Saves the cookies defined in SetCookieHeaders
+ in the client profile's cookie database. You need to
+ call this function if you set the option cookies to Returns the cookie header that would be sent
+ when making a request to Url using the profile Profile.
+ If no profile is specified the default profile will be used.
+ Resets (clears) the cookie database for the specified Profile.
+ If no profile is specified the default profile will be used.
+ This function produces a list of the entire cookie database.
+ It is intended for debugging/testing purposes.
+ If no profile is specified the default profile will be used.
+ RFC 2616, With a few exceptions, that are documented
@@ -103,9 +103,9 @@
as:
+
+
+
+
+
+{http, ReplyInfo}
+
+
+Receiver(ReplyInfo)
+
+
+apply(Module, Function, [ReplyInfo | Args])
+
+
+{RequestId, saved_to_file}
+{RequestId, {error, Reason}}
+{RequestId, Result}
+{RequestId, stream_start, Headers}
+{RequestId, stream_start, Headers, HandlerPid}
+{RequestId, stream, BinBodyPart}
+{RequestId, stream_end, Headers}
+
+
+
- {server_root, "/urs/local/www"} -> ServerRoot /usr/local/www
+{server_root, "/urs/local/www"} -> ServerRoot /usr/local/www
-
- \011 # MIME type\011\011\011Extension - \011 text/html\011\011\011html htm - \011 text/plain\011\011\011asc txt +# MIME type Extension +text/html html htm +text/plain asc txt
Defaults to [{"html","text/html"},{"htm","text/html"}]
@@ -869,19 +869,19 @@ bytes ModData = #mod{} -record(mod, { -\011\011data = [], -\011\011socket_type = ip_comm, -\011\011socket, -\011\011config_db, -\011\011method, -\011\011absolute_uri, -\011\011request_uri, -\011\011http_version, -\011\011request_line, -\011\011parsed_header = [], -\011\011entity_body, -\011\011connection -\011 }). + data = [], + socket_type = ip_comm, + socket, + config_db, + method, + absolute_uri, + request_uri, + http_version, + request_line, + parsed_header = [], + entity_body, + connection + }).The fields of the
Dynamically starts an inets service after the inets - application has been started.\011
+ application has been started.Dynamically started services will not be handled by
application takeover and failover behavior when inets is
diff --git a/lib/inets/doc/src/make.dep b/lib/inets/doc/src/make.dep
index d96c6dc5b8..8deb7e7a5a 100644
--- a/lib/inets/doc/src/make.dep
+++ b/lib/inets/doc/src/make.dep
@@ -1,3 +1,23 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1999-2010. All Rights Reserved.
+#
+# The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+
# ----------------------------------------------------
# >>>> Do not edit this file <<<<
# This file was automaticly generated by
@@ -9,7 +29,7 @@
# TeX files that the DVI file depend on
# ----------------------------------------------------
-book.dvi: book.tex ftp.tex ftp_client.tex http.tex http_client.tex \
+book.dvi: book.tex ftp.tex ftp_client.tex httpc.tex http_client.tex \
http_server.tex httpd.tex httpd_conf.tex httpd_socket.tex \
httpd_util.tex inets.tex inets_services.tex \
mod_alias.tex mod_auth.tex mod_esi.tex mod_security.tex \
diff --git a/lib/inets/doc/src/mod_esi.xml b/lib/inets/doc/src/mod_esi.xml
index d4541a1d15..6bad77dc0a 100644
--- a/lib/inets/doc/src/mod_esi.xml
+++ b/lib/inets/doc/src/mod_esi.xml
@@ -4,7 +4,7 @@
-
+The documentation is now built with open source tools - (xsltproc and fop) that exists on most - platforms. One visible change is that the frames are removed.
-Own Id: OTP-8249
+[httpc] Fix bug crafting Host header when port is not 80.
+The host header should include the port number as well as the + host name when making a request to a server listening on a port + other than the HTTP default of 80. Currently, only the host + name is included. This is important to make the http client + more compliant with the HTTP specification.
+Own Id: OTP-8371
+Kelly McLaughlin
[httpc|httpd] http_chunk data handling/passing improvement.
+This is a modification to the http_chunk module to forward any + full chunk received, regardless of whether the size field for the + following chunk has been received yet. This allows http_chunk to + be used in situations where a long term HTTP connection is used to + send periodic status updates as individual chunks. Previously a + given chunk would not be forwarded to the client process until the + size for the next chunk had been read which rendered the module + difficult to use for the scenario described.
+Bernard Duggan
+Own Id: OTP-8351
+Include the inets test suite in the release of the + application.
+Own Id: OTP-8349
+[httpc] - It is now possible to configure the client to + deliver an async reply to more receivers then the calling + process.
+See the
+
Own Id: OTP-8106
+[httpd] - Methods "PUT" and "DELETE" now allowed.
+huntermorris@gmail.com
+Own Id: OTP-8103
+[httpc] Several more or less critical fixes:
+
+ Initial call between the httpc manager and request
+ handler was synchronous. When the manager starts a new request handler,
+ this is no longer a synchronous operation. Previously,
+ the new request handler made the connection to the
+ server and issuing of the first request (the reason
+ for starting it) in the gen_server init function.
+ If the connection for some reason "took some time",
+ the manager hanged, leaving all other activities by
+ that manager also hanging.
+
+
As a side-effect of these changes, some modules was also
+ renamed, and a new api module,
+
Own Id: OTP-8016
+*** POTENTIAL INCOMPATIBILITY ***
+Fixing minor Dialyzer and copyright problem.
+[httpd] The server did not fully support the documented module
+ callback api. Spicifically, the load function should be able to
+ return the atom
Own Id: OTP-8359
Fixing various documentation-related bugs (bad quotes).
+Own Id: OTP-8327
+Fixing minor Dialyzer and copyright problem(s).
+Own Id: OTP-8315
+[httpc] - Added basic sanity check of option value + combinations.
+adam.kocoloski@gmail.com
+Own Id: OTP-8056
+[httpc, httpd] - In some cases if a body contained the - sequence "\\r\ - 0" and was chunked encoded this sequence + sequence "\r\n0" and was chunked encoded this sequence was incorrectly interpreted as the last chunk.
Own Id: OTP-6264 Aux Id: OTP-6005
Own Id: OTP-5551 Aux Id: seq9854
The HTTP server now handles "GET /\\r\ - \\r\ - " as well as - "GET / \\r\ - \\r\ - ". According to the RFC the whitespace is - not needed.
+The HTTP server now handles + "GET /\r\n\r\n" + as well as + "GET / \r\n\r\n". + According to the RFC the whitespace is not needed.
Own Id: OTP-5552 Aux Id: seq8426
bar
"}, [], []) of + {ok, {{_,405,_}, [_ | _], [_ | _]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_delete(doc) -> + ["Perform a DELETE request that goes through a proxy. Note the server" + " will reject the request this is a test of the sending of the" + " request. But as the file does not exist the return code will" + " be 404 not found."]; +proxy_delete(suite) -> + []; +proxy_delete(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + URL = ?PROXY_URL ++ "/foobar.html", + case http:request(delete, {URL, []}, [], []) of + {ok, {{_,404,_}, [_ | _], [_ | _]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_headers(doc) -> + ["Use as many request headers as possible"]; +proxy_headers(suite) -> + []; +proxy_headers(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + {ok, {{_,200,_}, [_ | _], [_ | _]}} + = http:request(get, {?PROXY_URL, + [ + {"Accept", + "text/*, text/html," + " text/html;level=1," + " */*"}, + {"Accept-Charset", + "iso-8859-5, unicode-1-1;" + "q=0.8"}, + {"Accept-Encoding", "*"}, + {"Accept-Language", + "sv, en-gb;q=0.8," + " en;q=0.7"}, + {"User-Agent", "inets"}, + {"Max-Forwards","5"}, + {"Referer", + "http://otp.ericsson.se:8000" + "/product/internal"} + ]}, [], []), + ok; + Reason -> + {skip, Reason} + end. + +%%------------------------------------------------------------------------- +proxy_auth(doc) -> + ["Test the code for sending of proxy authorization."]; +proxy_auth(suite) -> + []; +proxy_auth(Config) when is_list(Config) -> + %% Our proxy seems to ignore the header, however our proxy + %% does not requirer an auth header, but we want to know + %% atleast the code for sending the header does not crash! + case ?config(skip, Config) of + undefined -> + case http:request(get, {?PROXY_URL, []}, + [{proxy_auth, {"foo", "bar"}}], []) of + {ok, {{_,200, _}, [_ | _], [_|_]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +http_server_does_not_exist(doc) -> + ["Test that we get an error message back when the server " + "does note exist."]; +http_server_does_not_exist(suite) -> + []; +http_server_does_not_exist(Config) when is_list(Config) -> + {error, _} = + http:request(get, {"http://localhost:" ++ + integer_to_list(?NOT_IN_USE_PORT) + ++ "/", []},[], []), + ok. + + +%%------------------------------------------------------------------------- +page_does_not_exist(doc) -> + ["Test that we get a 404 when the page is not found."]; +page_does_not_exist(suite) -> + []; +page_does_not_exist(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/doesnotexist.html", + {ok, {{_,404,_}, [_ | _], [_ | _]}} + = http:request(get, {URL, []}, [], []), + ok. + + +%%------------------------------------------------------------------------- +proxy_page_does_not_exist(doc) -> + ["Test that we get a 404 when the page is not found."]; +proxy_page_does_not_exist(suite) -> + []; +proxy_page_does_not_exist(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + URL = ?PROXY_URL ++ "/doesnotexist.html", + {ok, {{_,404,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, []}, [], []), + ok; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_https_not_supported(doc) -> + []; +proxy_https_not_supported(suite) -> + []; +proxy_https_not_supported(Config) when is_list(Config) -> + {error, https_through_proxy_is_not_currently_supported} + = http:request(get, {"https://login.yahoo.com", []}, [], []), + ok. + + +%%------------------------------------------------------------------------- + +http_stream(doc) -> + ["Test the option stream for asynchrony requests"]; +http_stream(suite) -> + []; +http_stream(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {URL, []}, [], []), + + {ok, RequestId} = + http:request(get, {URL, []}, [], [{sync, false}, + {stream, self}]), + + receive + {http, {RequestId, stream_start, _Headers}} -> + ok; + {http, Msg} -> + test_server:fail(Msg) + end, + + StreamedBody = receive_streamed_body(RequestId, <<>>), + + Body == binary_to_list(StreamedBody). + + +%%------------------------------------------------------------------------- +http_stream_once(doc) -> + ["Test the option stream for asynchrony requests"]; +http_stream_once(suite) -> + []; +http_stream_once(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + Port = receive + {port, ServerPort} -> + ServerPort + end, + + PortStr = integer_to_list(Port), + once(?URL_START ++ PortStr ++ "/once.html"), + once(?URL_START ++ PortStr ++ "/once_chunked.html"), + once(?URL_START ++ PortStr ++ "/dummy.html"), + + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + +once(URL) -> + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {URL, []}, [], []), + + {ok, RequestId} = + http:request(get, {URL, []}, [], [{sync, false}, + {stream, {self, once}}]), + + NewPid = receive + {http, {RequestId, stream_start, _Headers, Pid}} -> + Pid; + {http, Msg} -> + test_server:fail(Msg) + end, + + test_server:format("Request handler: ~p~n", [NewPid]), + + BodyPart = + receive + {http, {RequestId, stream, BinBodyPart}} -> + BinBodyPart + end, + + test_server:format("First body part: ~p~n", + [binary_to_list(BodyPart)]), + + StreamedBody = receive_streamed_body(RequestId, BinBodyPart, NewPid), + + Body = binary_to_list(StreamedBody), + ok. + + +%%------------------------------------------------------------------------- +proxy_stream(doc) -> + ["Test the option stream for asynchrony requests"]; +proxy_stream(suite) -> + []; +proxy_stream(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {?PROXY_URL, []}, [], []), + + {ok, RequestId} = + http:request(get, {?PROXY_URL, []}, [], + [{sync, false}, {stream, self}]), + + receive + {http, {RequestId, stream_start, _Headers}} -> + ok; + {http, Msg} -> + test_server:fail(Msg) + end, + + StreamedBody = receive_streamed_body(RequestId, <<>>), + + Body == binary_to_list(StreamedBody); + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +parse_url(doc) -> + ["Test that an url is parsed correctly"]; +parse_url(suite) -> + []; +parse_url(Config) when is_list(Config) -> + %% ipv6 + {http,[],"2010:836B:4179::836B:4179",80,"/foobar.html",[]} + = http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html"), + {error, + {malformed_url,"http://2010:836B:4179::836B:4179/foobar.html"}} = + http_uri:parse("http://2010:836B:4179::836B:4179/foobar.html"), + + %% ipv4 + {http,[],"127.0.0.1",80,"/foobar.html",[]} = + http_uri:parse("http://127.0.0.1/foobar.html"), + + %% host + {http,[],"localhost",8888,"/foobar.html",[]} = + http_uri:parse("http://localhost:8888/foobar.html"), + + %% Userinfo + {http,"nisse:foobar","localhost",8888,"/foobar.html",[]} = + http_uri:parse("http://nisse:foobar@localhost:8888/foobar.html"), + + %% Scheme error + {error,no_scheme} = http_uri:parse("localhost/foobar.html"), + {error,{not_supported_scheme,localhost}} = + http_uri:parse("localhost:8888/foobar.html"), + + %% Query + {http,[],"localhost",8888,"/foobar.html","?foo=bar&foobar=42"} = + http_uri:parse("http://localhost:8888/foobar.html?foo=bar&foobar=42"), + + %% Esc chars + {http,[],"www.somedomain.com",80,"/%2Eabc",[]} = + http_uri:parse("http://www.somedomain.com/%2Eabc"), + {http,[],"www.somedomain.com",80,"/%252Eabc",[]} = + http_uri:parse("http://www.somedomain.com/%252Eabc"), + {http,[],"www.somedomain.com",80,"/%25abc",[]} = + http_uri:parse("http://www.somedomain.com/%25abc"), + {http,[],"www.somedomain.com",80,"/%25abc", "?foo=bar"} = + http_uri:parse("http://www.somedomain.com/%25abc?foo=bar"), + ok. + + +%%------------------------------------------------------------------------- +ipv6(doc) -> + ["Test ipv6."]; +ipv6(suite) -> + []; +ipv6(Config) when is_list(Config) -> + {ok, Hostname} = inet:gethostname(), + + case lists:member(list_to_atom(Hostname), + ?config(ipv6_hosts, Config)) of + true -> + DummyServerPid = dummy_server(self(), ipv6), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = "http://[" ++ ?IPV6_LOCAL_HOST ++ "]:" ++ + integer_to_list(Port) ++ "/foobar.html", + {ok, {{_,200,_}, [_ | _], [_|_]}} = + http:request(get, {URL, []}, [], []), + + DummyServerPid ! stop, + ok; + false -> + {skip, "Host does not support IPv6"} + end. + + +%%------------------------------------------------------------------------- +headers_as_is(doc) -> + ["Test the option headers_as_is"]; +headers_as_is(suite) -> + []; +headers_as_is(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_|_], [_|_]}} = + http:request(get, {URL, [{"Host", "localhost"},{"Te", ""}]}, + [], [{headers_as_is, true}]), + + {ok, {{_,400,_}, [_|_], [_|_]}} = + http:request(get, {URL, [{"Te", ""}]},[], [{headers_as_is, true}]), + ok. + + +%%------------------------------------------------------------------------- +options(doc) -> + ["Test the option parameters."]; +options(suite) -> + []; +options(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_ | _], Bin}} + = http:request(get, {URL, []}, [{foo, bar}], + %% Ignore unknown options + [{body_format, binary}, {foo, bar}]), + + true = is_binary(Bin), + {ok, {200, [_|_]}} + = http:request(get, {URL, []}, [{timeout, infinity}], + [{full_result, false}]); + _ -> + {skip, "Failed to start local http-server"} + end. + + +%%------------------------------------------------------------------------- +http_invalid_http(doc) -> + ["Test parse error"]; +http_invalid_http(suite) -> + []; +http_invalid_http(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/invalid_http.html", + + {error, {could_not_parse_as_http, _} = Reason} = + http:request(get, {URL, []}, [], []), + + test_server:format("Parse error: ~p ~n", [Reason]), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +hexed_query_otp_6191(doc) -> + []; +hexed_query_otp_6191(suite) -> + []; +hexed_query_otp_6191(Config) when is_list(Config) -> + Google = "www.google.com", + GoogleSearch = "http://" ++ Google ++ "/search", + Search1 = "?hl=en&q=a%D1%85%D1%83%D0%B9&btnG=Google+Search", + URI1 = GoogleSearch ++ Search1, + Search2 = "?hl=en&q=%25%25", + URI2 = GoogleSearch ++ Search2, + Search3 = "?hl=en&q=%foo", + URI3 = GoogleSearch ++ Search3, + + {http, [], Google, 80, "/search", _} = http_uri:parse(URI1), + {http, [], Google, 80, "/search", _} = http_uri:parse(URI2), + {http, [], Google, 80, "/search", _} = http_uri:parse(URI3), + ok. + + +%%------------------------------------------------------------------------- + +empty_body_otp_6243(doc) -> + ["An empty body was not returned directly. There was a delay for several" + "seconds."]; +empty_body_otp_6243(suite) -> + []; +empty_body_otp_6243(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/empty.html", + {ok, {{_,200,_}, [_ | _], []}} = + http:request(get, {URL, []}, [{timeout, 500}], []). + + +%%------------------------------------------------------------------------- + +transfer_encoding_otp_6807(doc) -> + ["Transfer encoding is case insensitive"]; +transfer_encoding_otp_6807(suite) -> + []; +transfer_encoding_otp_6807(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ + "/capital_transfer_encoding.html", + {ok, {{_,200,_}, [_|_], [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +proxy_not_modified_otp_6821(doc) -> + ["If unmodified no body should be returned"]; +proxy_not_modified_otp_6821(suite) -> + []; +proxy_not_modified_otp_6821(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + provocate_not_modified_bug(?PROXY_URL); + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- + +empty_response_header_otp_6830(doc) -> + ["Test the case that the HTTP server does not send any headers"]; +empty_response_header_otp_6830(suite) -> + []; +empty_response_header_otp_6830(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/no_headers.html", + {ok, {{_,200,_}, [], [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +no_content_204_otp_6982(doc) -> + ["Test the case that the HTTP 204 no content header"]; +no_content_204_otp_6982(suite) -> + []; +no_content_204_otp_6982(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/no_content.html", + {ok, {{_,204,_}, [], []}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +missing_CR_otp_7304(doc) -> + ["Test the case that the HTTP server uses only LF instead of CRLF" + "as delimitor"]; +missing_CR_otp_7304(suite) -> + []; +missing_CR_otp_7304(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/missing_CR.html", + {ok, {{_,200,_}, _, [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +otp_7883(suite) -> + [otp_7883_1, otp_7883_2]. + +otp_7883_1(doc) -> + ["OTP-7883-sync"]; +otp_7883_1(suite) -> + []; +otp_7883_1(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/just_close.html", + {error, socket_closed_remotely} = http:request(URL), + DummyServerPid ! stop, + + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + +otp_7883_2(doc) -> + ["OTP-7883-async"]; +otp_7883_2(suite) -> + []; +otp_7883_2(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + + DummyServerPid = dummy_server(self(), ipv4), + + Port = receive + {port, ServerPort} -> + ServerPort + end, + + URL = ?URL_START ++ integer_to_list(Port) ++ "/just_close.html", + Method = get, + Request = {URL, []}, + HttpOptions = [], + Options = [{sync, false}], + Profile = http:default_profile(), + {ok, RequestId} = + http:request(Method, Request, HttpOptions, Options, Profile), + ok = + receive + {http, {RequestId, {error, socket_closed_remotely}}} -> + ok + end, + DummyServerPid ! stop, + + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +otp_8154(suite) -> + [otp_8154_1]. + +otp_8154_1(doc) -> + ["OTP-8154"]; +otp_8154_1(suite) -> + []; +otp_8154_1(Config) when is_list(Config) -> + start_inets(), + ReqSeqNumServer = start_sequence_number_server(), + RespSeqNumServer = start_sequence_number_server(), + {ok, Server, Port} = start_slow_server(RespSeqNumServer), + Clients = run_clients(105, Port, ReqSeqNumServer), + %% ok = wait_for_clients(Clients), + ok = wait4clients(Clients, timer:minutes(2)), + Server ! shutdown, + RespSeqNumServer ! shutdown, + ReqSeqNumServer ! shutdown, + ok. + +start_inets() -> + inets:start(), + ok. + +%% ----------------------------------------------------- +%% A sequence number handler +%% The purpose is to be able to pair requests with responses. + +start_sequence_number_server() -> + proc_lib:spawn(fun() -> loop_sequence_number(1) end). + +loop_sequence_number(N) -> + receive + shutdown -> + ok; + {From, get_next} -> + From ! {next_is, N}, + loop_sequence_number(N + 1) + end. + +get_next_sequence_number(SeqNumServer) -> + SeqNumServer ! {self(), get_next}, + receive {next_is, N} -> N end. + +%% ----------------------------------------------------- +%% Client part +%% Sends requests randomly parallel + +run_clients(NumClients, ServerPort, SeqNumServer) -> + io:format("start clients when" + "~n NumClients: ~w" + "~n ServerPort: ~w" + "~n SeqNumServer: ~w" + "~n", [NumClients, ServerPort, SeqNumServer]), + set_random_seed(), + lists:map( + fun(Id) -> + io:format("starting client ~w~n", [Id]), + Req = f("req~3..0w", [get_next_sequence_number(SeqNumServer)]), + Url = f(?URL_START ++ "~w/~s", [ServerPort, Req]), + Pid = proc_lib:spawn( + fun() -> + io:format("[~w] client started - " + "issue request~n", [Id]), + case http:request(Url) of + {ok, {{_,200,_}, _, Resp}} -> + io:format("[~w] 200 response: " + "~p~n", [Id, Resp]), + case lists:prefix(Req++"->", Resp) of + true -> exit(normal); + false -> exit({bad_resp,Req,Resp}) + end; + {ok, {{_,EC,Reason},_,Resp}} -> + io:format("[~w] ~w response: " + "~s~n~s~n", + [Id, EC, Reason, Resp]), + exit({bad_resp,Req,Resp}); + Crap -> + io:format("[~w] bad response: ~p", + [Id, Crap]), + exit({bad_resp, Req, Crap}) + end + end), + MRef = erlang:monitor(process, Pid), + timer:sleep(10 + random:uniform(1334)), + {Id, Pid, MRef} + + end, + lists:seq(1, NumClients)). + +wait_for_clients(Clients) -> + lists:foreach( + fun({Id, Pid, MRef}) -> + io:format("waiting for client ~w termination~n", [Id]), + receive + {'DOWN', MRef, process, Pid, normal} -> + io:format("waiting for clients: " + "normal exit from ~w (~p)~n", + [Id, Pid]), + ok; + {'DOWN', MRef, process, Pid, Reason} -> + io:format("waiting for clients: " + "unexpected exit from ~w (~p):" + "~n Reason: ~p" + "~n", [Id, Pid, Reason]), + erlang:error(Reason) + end + end, + Clients). + + +wait4clients([], _Timeout) -> + ok; +wait4clients(Clients, Timeout) when Timeout > 0 -> + io:format("wait4clients -> entry with" + "~n length(Clients): ~w" + "~n Timeout: ~w" + "~n", [length(Clients), Timeout]), + T = t(), + receive + {'DOWN', _MRef, process, Pid, normal} -> + case lists:keysearch(Pid, 2, Clients) of + {value, {Id, _, _}} -> + io:format("receive normal exit message " + "from client ~p (~p)", [Id, Pid]), + NewClients = + lists:keydelete(Id, 1, Clients), + wait4clients(NewClients, + Timeout - (t() - T)); + false -> + io:format("receive normal exit message " + "from unknown process: ~p", [Pid]), + wait4clients(Clients, Timeout - (t() - T)) + end; + + {'DOWN', _MRef, process, Pid, Reason} -> + case lists:keysearch(Pid, 2, Clients) of + {value, {Id, _, _}} -> + io:format("receive bad exit message " + "from client ~p (~p):" + "~n ~p", [Id, Pid, Reason]), + erlang:error({bad_client_termination, Id, Reason}); + false -> + io:format("receive normal exit message " + "from unknown process: ~p", [Pid]), + wait4clients(Clients, Timeout - (t() - T)) + end + + after Timeout -> + erlang:error({client_timeout, Clients}) + end; +wait4clients(Clients, _) -> + erlang:error({client_timeout, Clients}). + + +%% Time in milli seconds +t() -> + {A,B,C} = erlang:now(), + A*1000000000+B*1000+(C div 1000). + + +%% ----------------------------------------------------- +%% Webserver part: +%% Implements a web server that sends responses one character +%% at a time, with random delays between the characters. + +start_slow_server(SeqNumServer) -> + io:format("start slow server when" + "~n SeqNumServer: ~w" + "~n", [SeqNumServer]), + proc_lib:start( + erlang, apply, [fun() -> init_slow_server(SeqNumServer) end, []]). + +init_slow_server(SeqNumServer) -> + io:format("[webserver ~w] init slow server" + "~n", [SeqNumServer]), + {ok, LSock} = gen_tcp:listen(0, [binary, {packet,0}, {active,true}, + {backlog, 100}]), + io:format("[webserver ~w] LSock: ~p" + "~n", [SeqNumServer, LSock]), + {ok, {_IP, Port}} = inet:sockname(LSock), + io:format("[webserver ~w] Port: ~w" + "~n", [SeqNumServer, Port]), + proc_lib:init_ack({ok, self(), Port}), + loop_slow_server(LSock, SeqNumServer). + +loop_slow_server(LSock, SeqNumServer) -> + io:format("[webserver ~w] entry with" + "~n LSock: ~p" + "~n", [SeqNumServer, LSock]), + Master = self(), + Acceptor = proc_lib:spawn( + fun() -> client_handler(Master, LSock, SeqNumServer) end), + io:format("[webserver ~w] acceptor started" + "~n Acceptor: ~p" + "~n", [SeqNumServer, Acceptor]), + receive + {accepted, Acceptor} -> + io:format("[webserver ~w] accepted" + "~n", [SeqNumServer]), + loop_slow_server(LSock, SeqNumServer); + shutdown -> + gen_tcp:close(LSock), + exit(Acceptor, kill) + end. + + +%% Handle one client connection +client_handler(Master, LSock, SeqNumServer) -> + io:format("[acceptor ~w] await accept" + "~n", [SeqNumServer]), + {ok, CSock} = gen_tcp:accept(LSock), + io:format("[acceptor ~w] accepted" + "~n CSock: ~p" + "~n", [SeqNumServer, CSock]), + Master ! {accepted, self()}, + set_random_seed(), + loop_client(1, CSock, SeqNumServer). + +loop_client(N, CSock, SeqNumServer) -> + %% Await request, don't bother parsing it too much, + %% assuming the entire request arrives in one packet. + io:format("[acceptor ~w] await request" + "~n N: ~p" + "~n", [SeqNumServer, N]), + receive + {tcp, CSock, Req} -> + ReqNum = parse_req_num(Req), + RespSeqNum = get_next_sequence_number(SeqNumServer), + Response = f("~s->resp~3..0w/~2..0w", [ReqNum, RespSeqNum, N]), + Txt = f("Slow server (~p) got ~p, answering with ~p", + [self(), Req, Response]), + io:format("~s...~n", [Txt]), + slowly_send_response(CSock, Response), + case parse_connection_type(Req) of + keep_alive -> + io:format("~s...done~n", [Txt]), + loop_client(N+1, CSock, SeqNumServer); + close -> + io:format("~s...done (closing)~n", [Txt]), + gen_tcp:close(CSock) + end + end. + +slowly_send_response(CSock, Answer) -> + Response = f("HTTP/1.1 200 OK\r\nContent-Length: ~w\r\n\r\n~s", + [length(Answer), Answer]), + lists:foreach( + fun(Char) -> + timer:sleep(random:uniform(500)), + gen_tcp:send(CSock, <This is a dummy html file!
+ + diff --git a/lib/inets/test/httpc_SUITE_data/empty.html b/lib/inets/test/httpc_SUITE_data/empty.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/inets/test/httpc_SUITE_data/mime.types b/lib/inets/test/httpc_SUITE_data/mime.types new file mode 100644 index 0000000000..d2f81e4e5e --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/mime.types @@ -0,0 +1,465 @@ +# This is a comment. I love comments. + +# MIME type Extension +application/EDI-Consent +application/EDI-X12 +application/EDIFACT +application/activemessage +application/andrew-inset ez +application/applefile +application/atomicmail +application/batch-SMTP +application/beep+xml +application/cals-1840 +application/commonground +application/cybercash +application/dca-rft +application/dec-dx +application/dvcs +application/eshop +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/font-tdpfr +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica +application/mathematica-old +application/msword doc +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin dms lha lzh exe class so dll +application/oda oda +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys +application/pgp-signature +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/postscript ai eps ps +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/remote-printing +application/riscos +application/rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/vnd.3M.Post-it-Notes +application/vnd.FloGraphIt +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.businessobjects +application/vnd.bmi +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.ctc-posml +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.afplinedata +application/vnd.ibm.MiniPay +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls +application/vnd.ms-lrm +application/vnd.ms-powerpoint ppt +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.street-stream +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/whoispp-query +application/whoispp-response +application/wita +application/wordperfect5.1 +application/x-bcpio bcpio +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-director dcr dir dxr +application/x-dvi dvi +application/x-futuresplash spl +application/x-gtar gtar +application/x-gzip +application/x-hdf hdf +application/x-javascript js +application/x-koan skp skd skt skm +application/x-latex latex +application/x-netcdf nc cdf +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-stuffit sit +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-texinfo texinfo texi +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-wais-source src +application/x400-bp +application/xml +application/xml-dtd +application/xml-external-parsed-entity +application/zip zip +audio/32kadpcm +audio/basic au snd +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mp2 mp3 +audio/parityfec +audio/prs.sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-pn-realaudio ram rm +audio/x-pn-realaudio-plugin rpm +audio/x-realaudio ra +audio/x-wav wav +chemical/x-pdb pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/png png +image/prs.btif +image/prs.pti +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/news +message/partial +message/rfc822 +message/s-http +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message +text/calendar +text/css css +text/directory +text/enriched +text/html html htm +text/parityfec +text/plain asc txt +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf rtf +text/sgml sgml sgm +text/tab-separated-values tsv +text/t140 +text/uri-list +text/vnd.DMClientScript +text/vnd.IPTC.NITF +text/vnd.IPTC.NewsML +text/vnd.abc +text/vnd.curl +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-setext etx +text/x-server-parsed-html shtml +text/xml xml xsl +text/xml-external-parsed-entity +video/mp4v-es +video/mpeg mpeg mpg mpe +video/parityfec +video/pointer +video/quicktime qt mov +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice + + + diff --git a/lib/inets/test/httpc_SUITE_data/redirect.html b/lib/inets/test/httpc_SUITE_data/redirect.html new file mode 100644 index 0000000000..7034461ed6 --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/redirect.html @@ -0,0 +1,10 @@ + + + +You will be redirected
+ diff --git a/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem b/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem new file mode 100644 index 0000000000..f274d2021d --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOwIBAAJBANz7eFvORmJDi1XJMM2U3uHC5wmp/DXTLMw08XaEvtZ73wgVg84E +V0oyX3Kh1thRE3Hch9AyrHjgpizCj9/Ra38CAwEAAQJACzpz2SZYCTIpaEh6xFdm +I86FcsZCXHHIeu/NvRntoHQ+nfM7Np379+z6XNJWIcWh/QgG/jNJalR1BO+eyc6/ +YQIhAP3m8M0LDxJwSgHFtGAGatQqaqw9l48Kq5xdMFqvdpiHAiEA3s7lld6yCJYu +6q7fZjTH+eKUwgg0vpgJutP7Fsok60kCIHHesQBEhW3vjkFdOZgXSLH+k/jLZr1w +O6bU5GrHZpjhAiEAyTvGYcjDtTunXjDY9l+fadK6FlEBCk8ZIpNIiTnDhHkCIQDr +QxxLLuNHRj8iWNbuVVZ99SJy8zC33pMgPFaFKaZesQ== +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIB7jCCAZgCAQAwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlNFMRIwEAYD +VQQHEwlTdG9ja2hvbG0xETAPBgNVBAoTCEVyaWNzc29uMQwwCgYDVQQLEwNFVFgx +FjAUBgNVBAMTDUhlbGVuIEFpcml5YW4xJTAjBgkqhkiG9w0BCQEWFmhlbGVuQGVy +aXguZXJpY3Nzb24uc2UwHhcNOTcwNzI4MDcxNDI1WhcNOTgxMjEwMDcxNDI1WjCB +gTELMAkGA1UEBhMCU0UxEjAQBgNVBAcTCVN0b2NraG9sbTERMA8GA1UEChMIRXJp +Y3Nzb24xDDAKBgNVBAsTA0VUWDEWMBQGA1UEAxMNSGVsZW4gQWlyaXlhbjElMCMG +CSqGSIb3DQEJARYWaGVsZW5AZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEB +AQUAA0sAMEgCQQDc+3hbzkZiQ4tVyTDNlN7hwucJqfw10yzMNPF2hL7We98IFYPO +BFdKMl9yodbYURNx3IfQMqx44KYswo/f0Wt/AgMBAAEwDQYJKoZIhvcNAQEEBQAD +QQC2++hLIaQJ4ChCjFE9UCfXO9cZ3Vq/FT9VjE+G4MRBDo4LQ5mBKNXcPF6EFZmi +7XrlvopXkVPlRguTi2SLRPkY +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem b/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem new file mode 100644 index 0000000000..f01b6c992b --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOQIBAAJBAMe2WhP6s+JeKOwWPEjI9susfN4Vjn2dd1X4QUlOETcWVLoF916m +M4JU+ms7+ciMR8GRNCsIeqZGY8/GSqm74ccCAwEAAQJAF08YKlbLYfM9cXiS5qfV +7iWemUkIzW5wfC8yZ3zeE4Cp6R9ViUfs/dadQ/23Cw0Bpo2t8UdTUdCa4KpmqOem +cQIhAOnxTWZ5eo6h6PXDp7L5FZUACg8+wT3qf5f2is2mbSZPAiEA2orUY8JZDTSk +Rm7q9WxLiLNtORsXdTCmnCWhqBOYpwkCIErdowRxScxNekz0IT3AQqzdR1rbnWHg +IpcSGhd39CQ3AiA1XvQxjLP8wp9fyBS/bPwhXVhOOuyGpSP7PEF3b5m3KQIgGQWc +/a5wuWx3pc3mLx0ILwNoJr2ubFEuW1PJPsPJPv0= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIB7jCCAZgCAQAwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlNFMRIwEAYD +VQQHEwlTdG9ja2hvbG0xETAPBgNVBAoTCEVyaWNzc29uMQwwCgYDVQQLEwNFVFgx +FjAUBgNVBAMTDUhlbGVuIEFpcml5YW4xJTAjBgkqhkiG9w0BCQEWFmhlbGVuQGVy +aXguZXJpY3Nzb24uc2UwHhcNOTcwNzI4MDcyMTAwWhcNOTgxMjEwMDcyMTAwWjCB +gTELMAkGA1UEBhMCU0UxEjAQBgNVBAcTCVN0b2NraG9sbTERMA8GA1UEChMIRXJp +Y3Nzb24xDDAKBgNVBAsTA0VUWDEWMBQGA1UEAxMNSGVsZW4gQWlyaXlhbjElMCMG +CSqGSIb3DQEJARYWaGVsZW5AZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEB +AQUAA0sAMEgCQQDHtloT+rPiXijsFjxIyPbLrHzeFY59nXdV+EFJThE3FlS6Bfde +pjOCVPprO/nIjEfBkTQrCHqmRmPPxkqpu+HHAgMBAAEwDQYJKoZIhvcNAQEEBQAD +QQCnU1TkxmfbLdUwjdECb5x9QHCevAR7AmTms4Csn2oOEyPX+bgF2d94xhrV1sxO +Rs0yigk1PtN17Ci0Dey0LYkR +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpc_cookie_SUITE.erl b/lib/inets/test/httpc_cookie_SUITE.erl new file mode 100644 index 0000000000..7d91631934 --- /dev/null +++ b/lib/inets/test/httpc_cookie_SUITE.erl @@ -0,0 +1,338 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpc_cookie_SUITE). + +-include("test_server.hrl"). +-include_lib("stdlib/include/ms_transform.hrl"). + +%% Test server specific exports +-export([all/1, init_per_testcase/2, end_per_testcase/2]). + +%% Test cases must be exported. +-export([session_cookies_only/1, netscape_cookies/1, + cookie_cancel/1, cookie_expires/1, persistent_cookie/1, + domain_cookie/1, secure_cookie/1, update_cookie/1, + update_cookie_session/1, cookie_attributes/1]). + +-define(URL, "http://myhost.cookie.test.org"). +-define(URL_DOMAIN, "http://myhost2.cookie.test.org"). +-define(URL_SECURE, "https://myhost.cookie.test.org"). + +%% Test server callback functions + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(session_cookies_only, Config) -> + application:start(inets), + http:set_options([{cookies, verify}]), + watch_dog(Config); + +init_per_testcase(_, Config) -> + PrivDir = ?config(priv_dir, Config), + application:load(inets), + application:set_env(inets, services, [{httpc,{default, PrivDir}}]), + application:start(inets), + http:set_options([{cookies, verify}]), + watch_dog(Config). + +watch_dog(Config) -> + Dog = test_server:timetrap(inets_test_lib:minutes(10)), + NewConfig = lists:keydelete(watchdog, 1, Config), + [{watchdog, Dog} | NewConfig]. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, Config) -> + application:stop(inets), + File = filename:join(?config(priv_dir, Config), "http_default_cookie_db"), + file:delete(File), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Describe the main purpose of this suite"]; + +all(suite) -> + [session_cookies_only, netscape_cookies, cookie_cancel, + cookie_expires, persistent_cookie, domain_cookie, secure_cookie, + update_cookie, update_cookie_session, cookie_attributes]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +session_cookies_only(doc) -> + ["Test that all cookies are handled as session cookies if there" + "does not exist a directory to save presitent cookies in."]; +session_cookies_only(suite) -> + []; +session_cookies_only(Config) when is_list(Config) -> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + ";max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + application:stop(inets), + application:start(inets), + {"cookie",""} + = http:cookie_header(?URL), + ok. + +netscape_cookies(doc) -> + ["Test that the old (original) format of cookies are accepted."]; +netscape_cookies(suite) -> + []; +netscape_cookies(Config) when is_list(Config) -> + Expires = future_netscape_date(), + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; " + "expires=" ++ Expires}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + ok. + +cookie_cancel(doc) -> + ["A cookie can be canceld by sending the same cookie with max-age=0 " + "this test cheks that cookie is canceled."]; +cookie_cancel(suite) -> + []; +cookie_cancel(Config) when is_list(Config) -> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=0"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", ""} = http:cookie_header(?URL), + ok. + +cookie_expires(doc) -> + ["Test that a cookie is not used when it has expired"]; +cookie_expires(suite) -> + []; +cookie_expires(Config) when is_list(Config) -> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=5"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + test_server:sleep(10000), + {"cookie", ""} = http:cookie_header(?URL), + ok. + +persistent_cookie(doc)-> + ["Test domian cookie attribute"]; +persistent_cookie(suite) -> + []; +persistent_cookie(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + PrivDir = ?config(priv_dir, Config), + application:stop(inets), + application:load(inets), + application:set_env(inets, services, [{httpc,{default, PrivDir}}]), + application:start(inets), + http:set_options([{cookies, enabled}]), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + ok. + +domain_cookie(doc)-> + ["Test the domian cookie attribute"]; +domain_cookie(suite) -> + []; +domain_cookie(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "domain=.cookie.test.org"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/; " + "$Domain=.cookie.test.org"} + = http:cookie_header(?URL_DOMAIN), + ok. + +secure_cookie(doc)-> + ["Test the secure cookie attribute"]; +secure_cookie(suite) -> + []; +secure_cookie(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; secure"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL_SECURE), + {"cookie",""} + = http:cookie_header(?URL), + SetCookieHeaders1 = [{"set-cookie", "test1_cookie=true; path=/; secure"}], + http:verify_cookies(SetCookieHeaders1, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/; " + "test1_cookie=true; $Path=/"} = http:cookie_header(?URL_SECURE), + ok. + +update_cookie(doc)-> + ["Test that a cookie can be updated."]; +update_cookie(suite) -> + []; +update_cookie(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=6500"}, + {"set-cookie", "test_cookie2=true; path=/;" + "max-age=6500"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=true; $Path=/"} = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=false; " + "path=/;max-age=6500"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=false; $Path=/"} = http:cookie_header(?URL). + +update_cookie_session(doc)-> + ["Test that a cookie can be updated."]; +update_cookie_session(suite) -> + []; +update_cookie_session(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/"}, + {"set-cookie", "test_cookie2=true; path=/"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=true; $Path=/"} = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=false; path=/"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=false; $Path=/"} = http:cookie_header(?URL). + + +cookie_attributes(doc) -> + ["Test attribute not covered by the other test cases"]; +cookie_attributes(suite) -> + []; +cookie_attributes(Config) when is_list(Config) -> + SetCookieHeaders = [{"set-cookie", "test_cookie=true;version=1;" + "comment=foobar; "%% Comment + "foo=bar;" %% Nonsense should be ignored + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=1; test_cookie=true"} + = http:cookie_header(?URL), + ok. + +%%-------------------------------------------------------------------- +%%% Internal functions +%%-------------------------------------------------------------------- +future_netscape_date() -> + [Day, DD, Mon, YYYY] = netscape_date(date()), + lists:flatten(io_lib:format("~s, ~s ~s ~s 12:30:00 GMT", + [Day, DD, Mon, YYYY])). + +netscape_date({Year, 12, _}) -> + NewYear = Year + 1, + NewMonth = 1, + NewDay = calendar:last_day_of_the_month(NewYear, NewMonth), + WeekDay = calendar:day_of_the_week(NewYear, NewMonth, NewDay), + WeekDayNrStr = day_nr_str(NewDay), + NewDayStr = week_day_str(WeekDay), + MonthStr = month_str(NewMonth), + [NewDayStr, WeekDayNrStr, MonthStr, integer_to_list(NewYear)]; + +netscape_date({Year, Month, _}) -> + NewMonth = Month + 1, + NewDay = calendar:last_day_of_the_month(Year, NewMonth), + WeekDay = calendar:day_of_the_week(Year, NewMonth, NewDay), + WeekDayNrStr = day_nr_str(NewDay), + NewDayStr = week_day_str(WeekDay), + MonthStr = month_str(NewMonth), + [NewDayStr, WeekDayNrStr, MonthStr, integer_to_list(Year)]. + +week_day_str(1) -> + "Mon"; +week_day_str(2) -> + "Tus"; +week_day_str(3) -> + "Wdy"; +week_day_str(4) -> + "Thu"; +week_day_str(5) -> + "Fri"; +week_day_str(6) -> + "Sat"; +week_day_str(7) -> + "Sun". + +day_nr_str(1) -> + "01"; +day_nr_str(2) -> + "02"; +day_nr_str(3) -> + "03"; +day_nr_str(4) -> + "04"; +day_nr_str(5) -> + "05"; +day_nr_str(6) -> + "06"; +day_nr_str(7) -> + "07"; +day_nr_str(8) -> + "08"; +day_nr_str(0) -> + "09"; +day_nr_str(N) -> + integer_to_list(N). + +month_str(1) ->"Jan"; +month_str(2) ->"Feb"; +month_str(3) ->"Mar"; +month_str(4) ->"Apr"; +month_str(5) ->"May"; +month_str(6) ->"Jun"; +month_str(7) ->"Jul"; +month_str(8) ->"Aug"; +month_str(9) ->"Sep"; +month_str(10) ->"Oct"; +month_str(11) ->"Nov"; +month_str(12) ->"Dec". diff --git a/lib/inets/test/httpc_internal.hrl b/lib/inets/test/httpc_internal.hrl new file mode 120000 index 0000000000..bef2c94879 --- /dev/null +++ b/lib/inets/test/httpc_internal.hrl @@ -0,0 +1 @@ +../src/http_client/httpc_internal.hrl \ No newline at end of file diff --git a/lib/inets/test/httpd_1_1.erl b/lib/inets/test/httpd_1_1.erl new file mode 100644 index 0000000000..055d034bec --- /dev/null +++ b/lib/inets/test/httpd_1_1.erl @@ -0,0 +1,494 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_1_1). +-author('ingela@erix.ericsson.se'). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include_lib("kernel/include/file.hrl"). + +-export([host/4, chunked/4, expect/4, range/4, if_test/5, http_trace/4, + head/4, mod_cgi_chunked_encoding_test/5]). + +%% -define(all_keys_lower_case,true). +-ifndef(all_keys_lower_case). +-define(CONTENT_LENGTH, "Content-Length: "). +-define(CONTENT_RANGE, "Content-Range: "). +-define(CONTENT_TYPE, "Content-Type: "). +-else. +-define(CONTENT_LENGTH, "content-length:"). +-define(CONTENT_RANGE, "content-range:"). +-define(CONTENT_TYPE, "content-type:"). +-endif. + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +host(Type, Port, Host, Node) -> + %% No host needed for HTTP/1.0 + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + %% No host must generate an error + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n\r\n", + [{statuscode, 400}]), + + %% If it is a fully qualified URL no host is needed + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET HTTP://"++ Host ++ ":" ++ + integer_to_list(Port)++ + "/ HTTP/1.1\r\n\r\n", + [{statuscode, 200}]), + + %% If both look at the url. + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET HTTP://"++ Host ++ ":"++ + integer_to_list(Port) ++ + "/ HTTP/1.1\r\nHost:"++ Host ++ + "\r\n\r\n",[{statuscode, 200}]), + + %% Allow the request if its a Host field + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:"++ + Host ++ "\r\n\r\n", + [{statuscode, 200}]), + ok. + +chunked(Type, Port, Host, Node)-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n" + "Host:"++ Host ++"\r\n" + "Transfer-Encoding:chunked\r\n" + "\r\n" + "A\r\n" + "1234567890\r\n" + "4\r\n" + "HEJ!\r\n" + "0\r\n\r\n", + [{statuscode, 200}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n" + "Host:"++ Host ++"\r\n" + "Transfer-Encoding:chunked\r\n" + "Trailer:Content-Type\r\n" + "\r\n" + "A\r\n" + "1234567890\r\n" + "4\r\n" + "HEJ!\r\n" + "0\r\n" + "Content-Type:text/plain\r\n\r\n", + [{statuscode, 200}]), + ok. + +expect(Type, Port, Host, Node)-> + Request="GET / HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nContent-Length:22\r\nExpect:100-continue\r\n\r\n", + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + Request, + [{statuscode, 100}]). +range(Type, Port, Host, Node)-> + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /range.txt HTTP/1.1\r\nHost:" + ++ Host + ++ "\r\nRange:bytes=110-120\r\n\r\n", + [{statuscode,416}]), + %%The simples of all range request a range + Request1="GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=0-9\r\n\r\n", + {ok, Socket1} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket1,Request1), + ok = validateRangeRequest(Socket1,[],"1234567890",$2,$0,$6), + inets_test_lib:close(Type,Socket1), + + %% Request the end of the file + Request2 = + "GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=90-\r\n\r\n", + + {ok, Socket2} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket2, Request2), + ok = validateRangeRequest(Socket2,[],"1234567890",$2,$0,$6), + inets_test_lib:close(Type,Socket2), + + %% The last byte in the file + Request3 = + "GET /range.txt HTTP/1.1\r\nHost:"++ + Host ++ "\r\nRange:bytes=-1\r\n\r\n", + {ok, Socket3} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket3,Request3), + ok = validateRangeRequest(Socket3,[],"0",$2,$0,$6), + inets_test_lib:close(Type, Socket3), + + %%Multi Range + Request4 = "GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=0-0,2-2,-1\r\n\r\n", + {ok, Socket4} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket4, Request4), + ok = validateRangeRequest(Socket4,[],"130",$2,$0,$6), + inets_test_lib:close(Type, Socket4). + +if_test(Type, Port, Host, Node, DocRoot)-> + {ok, FileInfo} = + file:read_file_info(filename:join([DocRoot,"index.html"])), + CreatedSec = + calendar:datetime_to_gregorian_seconds(FileInfo#file_info.mtime), + + Mod = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec-1)), + + %% Test that we get the data when the file is modified + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nIf-Modified-Since:" ++ + Mod ++ "\r\n\r\n", + [{statuscode, 200}]), + Mod1 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec+100)), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++"\r\nIf-Modified-Since:" + ++ Mod1 ++"\r\n\r\n", + [{statuscode, 304}]), + + Mod2 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec+1)), + %% Control that the If-Unmodified-Header lmits the response + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ + "\r\nIf-Unmodified-Since:" ++ Mod2 + ++ "\r\n\r\n", + [{statuscode, 200}]), + Mod3 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec-1)), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ + "\r\nIf-Unmodified-Since:"++ Mod3 + ++"\r\n\r\n", + [{statuscode, 412}]), + + %% Control that we get the body when the etag match + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ Host + ++"\r\n"++ + "If-Match:"++ + httpd_util:create_etag(FileInfo)++ + "\r\n\r\n", + [{statuscode, 200}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ + Host ++ "\r\n"++ + "If-Match:NotEtag\r\n\r\n", + [{statuscode, 412}]), + + %% Control the response when the if-none-match header is there + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++"\r\n"++ + "If-None-Match:NoTaag," ++ + httpd_util:create_etag(FileInfo) ++ + "\r\n\r\n", + [{statuscode, 304}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ "\r\n"++ + "If-None-Match:NotEtag," + "NeihterEtag\r\n\r\n", + [{statuscode,200}]). + +http_trace(Type, Port, Host, Node)-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "TRACE / HTTP/1.1\r\n" ++ + "Host:" ++ Host ++ "\r\n" ++ + "Max-Forwards:2\r\n\r\n", + [{statuscode, 200}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "TRACE / HTTP/1.0\r\n\r\n", + [{statuscode, 501}, + {version, "HTTP/1.0"}]). +head(Type, Port, Host, Node)-> + %% mod_include + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /fsize.shtml HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /fsize.shtml HTTP/1.1\r\nhost:" ++ + Host ++ "\r\n\r\n", [{statuscode, 200}]), + %% mod_esi + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /cgi-bin/erl/httpd_example/newformat" + " HTTP/1.0\r\n\r\n", [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /cgi-bin/erl/httpd_example/newformat " + "HTTP/1.1\r\nhost:" ++ Host ++ "\r\n\r\n", + [{statuscode, 200}]), + %% mod_cgi + Script = + case test_server:os_type() of + {win32, _} -> + "printenv.bat"; + _ -> + "printenv.sh" + end, + ok = httpd_test_lib:verify_request(Type,Host,Port,Node,"HEAD /cgi-bin/" + ++ Script ++ " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, "HEAD /cgi-bin/" + ++ Script ++ " HTTP/1.1\r\nhost:" ++ + Host ++ "\r\n\r\n", + [{statuscode, 200}]). + +mod_cgi_chunked_encoding_test(_, _, _, _, [])-> + ok; +mod_cgi_chunked_encoding_test(Type, Port, Host, Node, [Request| Rest])-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, Request, + [{statuscode, 200}]), + mod_cgi_chunked_encoding_test(Type, Port, Host, Node, Rest). + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +validateRangeRequest(Socket,Response,ValidBody,C,O,DE)-> + receive + {tcp,Socket,Data} -> + case string:str(Data,"\r\n") of + 0-> + validateRangeRequest(Socket, + Response ++ Data, + ValidBody, C, O, DE); + _N -> + case Response ++ Data of + [$H,$T,$T,$P,$/,$1,$.,$1,$ ,C,O,DE | _Rest]-> + case [C,O,DE] of + "206" -> + validateRangeRequest1(Socket, + Response ++ Data, + ValidBody); + _ -> + bad_code + end; + _-> + error + end + end; + _Error -> + error + end. + +validateRangeRequest1(Socket, Response, ValidBody) -> + case end_of_header(Response) of + false -> + receive + {tcp,Socket,Data} -> + validateRangeRequest1(Socket, Response ++ Data, + ValidBody); + _-> + error + end; + {true, Head1, Body, _Size} -> + %% In this case size will be 0 if it is a multipart so + %% don't use it. + validateRangeRequest2(Socket, Head1, Body, ValidBody, + getRangeSize(Head1)) + end. + +validateRangeRequest2(Socket, Head, Body, ValidBody, {multiPart,Boundary})-> + case endReached(Body,Boundary) of + true -> + validateMultiPartRangeRequest(Body, ValidBody, Boundary); + false-> + receive + {tcp, Socket, Data} -> + validateRangeRequest2(Socket, Head, Body ++ Data, + ValidBody, {multiPart, Boundary}); + {tcp_closed, Socket} -> + error; + _ -> + error + end + end; + +validateRangeRequest2(Socket, Head, Body, ValidBody, BodySize) + when is_integer(BodySize) -> + case length(Body) of + Size when Size =:= BodySize -> + case Body of + ValidBody -> + ok; + Body -> + error + end; + Size when Size < BodySize -> + receive + {tcp, Socket, Data} -> + validateRangeRequest2(Socket, Head, + Body ++ Data, ValidBody, BodySize); + _ -> + error + end; + _ -> + error + end. + + +validateMultiPartRangeRequest(Body, ValidBody, Boundary)-> + case inets_regexp:split(Body,"--"++Boundary++"--") of + %%Last is the epilogue and must be ignored + {ok,[First | _Last]}-> + %%First is now the actuall http request body. + case inets_regexp:split(First, "--" ++ Boundary) of + %%Parts is now a list of ranges and the heads for each range + %%Gues we try to split out the body + {ok,Parts}-> + case lists:flatten(lists:map(fun splitRange/1,Parts)) of + ValidBody-> + ok; + ParsedBody-> + error = ParsedBody + end + end; + _ -> + error + end. + + +splitRange(Part)-> + case inets_regexp:split(Part, "\r\n\r\n") of + {ok,[_, Body]} -> + string:substr(Body, 1, length(Body) - 2); + _ -> + [] + end. + +endReached(Body, Boundary)-> + EndBound = "--" ++ Boundary ++ "--", + case string:str(Body, EndBound) of + 0 -> + false; + _ -> + true + end. + +getRangeSize(Head)-> + case controlMimeType(Head) of + {multiPart, BoundaryString}-> + {multiPart, BoundaryString}; + _X1 -> + case inets_regexp:match(Head, ?CONTENT_RANGE "bytes=.*\r\n") of + {match, Start, Lenght} -> + %% Get the range data remove the fieldname and the + %% end of line. + RangeInfo = string:substr(Head, Start + 20, + Lenght - (20 - 2)), + rangeSize(RangeInfo); + _X2 -> + error + end + end. +%%RangeInfo is NNN1-NNN2/NNN3 +%%NNN1=RangeStartByte +%%NNN2=RangeEndByte +%%NNN3=total amount of bytes in file +rangeSize([$=|RangeInfo]) -> + rangeSize(RangeInfo); +rangeSize(RangeInfo) -> + StartByte = lists:takewhile(fun(X)-> + num(X, true) + end, RangeInfo), + RangeInfo2 = string:substr(RangeInfo, length(StartByte) + 2), + EndByte = lists:takewhile(fun(X)-> + num(X,true) + end, RangeInfo2), + case list_to_integer(EndByte) - list_to_integer(StartByte) of + Val when is_number(Val) -> + %%Add one since it is startByte to endbyte ie 0-0 is 1 + %%byte 0-99 is 100 bytes + Val + 1; + _Val -> + error + end. + +num(CharVal, RetVal) when (CharVal >= 48) andalso (CharVal =< 57) -> + RetVal; +num(_CharVal, true) -> + false; +num(_CharVal, false) -> + true. + +controlMimeType(Head)-> + case inets_regexp:match(Head,?CONTENT_TYPE "multipart/byteranges.*\r\n") of + {match,Start,Length}-> + FieldNameLen = length(?CONTENT_TYPE "multipart/byteranges"), + case clearBoundary(string:substr(Head, Start + FieldNameLen, + Length - (FieldNameLen+2))) of + error -> + error; + BoundaryStr -> + {multiPart,BoundaryStr} + end; + nomatch-> + 0; + _ -> + error + end. + +clearBoundary(Boundary)-> + case inets_regexp:match(Boundary, "boundary=.*\$") of + {match, Start1, Length1}-> + BoundLen = length("boundary="), + string:substr(Boundary, Start1 + BoundLen, Length1 - BoundLen); + _ -> + error + end. + + +end_of_header(HeaderPart) -> + case httpd_util:split(HeaderPart,"\r\n\r\n",2) of + {ok, [Head, Body]} -> + {true, Head, Body, get_body_size(Head)}; + _Pos -> + false + end. + +get_body_size(Head) -> + case inets_regexp:match(Head,?CONTENT_LENGTH ".*\r\n") of + {match, Start, Length} -> + %% 15 is length of Content-Length, + %% 17 Is length of Content-Length and \r\ + S = list_to_integer( + string:strip(string:substr(Head, Start + 15, Length-17))), + S; + _-> + 0 + end. diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl new file mode 100644 index 0000000000..b7e97aa3ec --- /dev/null +++ b/lib/inets/test/httpd_SUITE.erl @@ -0,0 +1,2081 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("inets_test_lib.hrl"). + +-include_lib("kernel/include/file.hrl"). + +%% Test server specific exports +-export([all/1]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_suite/1, end_per_suite/1]). + +%% Test cases must be exported. +-export([ip/1, ssl/1, http_1_1_ip/1, http_1_0_ip/1, http_0_9_ip/1, + ipv6/1, tickets/1]). + +%% Core Server tests +-export([ip_mod_alias/1, ip_mod_actions/1, ip_mod_security/1, ip_mod_auth/1, + ip_mod_auth_api/1, ip_mod_auth_mnesia_api/1, + ip_mod_htaccess/1, ip_mod_cgi/1, ip_mod_esi/1, + ip_mod_get/1, ip_mod_head/1, ip_mod_all/1, ip_load_light/1, + ip_load_medium/1, ip_load_heavy/1, ip_dos_hostname/1, + ip_time_test/1, ip_block_disturbing_idle/1, + ip_block_non_disturbing_idle/1, ip_block_503/1, + ip_block_disturbing_active/1, ip_block_non_disturbing_active/1, + ip_block_disturbing_active_timeout_not_released/1, + ip_block_disturbing_active_timeout_released/1, + ip_block_non_disturbing_active_timeout_not_released/1, + ip_block_non_disturbing_active_timeout_released/1, + ip_block_disturbing_blocker_dies/1, + ip_block_non_disturbing_blocker_dies/1, + ip_restart_no_block/1, ip_restart_disturbing_block/1, + ip_restart_non_disturbing_block/1 + ]). + +-export([ssl_mod_alias/1, ssl_mod_actions/1, ssl_mod_security/1, + ssl_mod_auth/1, ssl_mod_auth_api/1, + ssl_mod_auth_mnesia_api/1, ssl_mod_htaccess/1, + ssl_mod_cgi/1, ssl_mod_esi/1, ssl_mod_get/1, ssl_mod_head/1, + ssl_mod_all/1, ssl_load_light/1, ssl_load_medium/1, + ssl_load_heavy/1, ssl_dos_hostname/1, ssl_time_test/1, + ssl_restart_no_block/1, ssl_restart_disturbing_block/1, + ssl_restart_non_disturbing_block/1, ssl_block_disturbing_idle/1, + ssl_block_non_disturbing_idle/1, ssl_block_503/1, + ssl_block_disturbing_active/1, ssl_block_non_disturbing_active/1, + ssl_block_disturbing_active_timeout_not_released/1, + ssl_block_disturbing_active_timeout_released/1, + ssl_block_non_disturbing_active_timeout_not_released/1, + ssl_block_non_disturbing_active_timeout_released/1, + ssl_block_disturbing_blocker_dies/1, + ssl_block_non_disturbing_blocker_dies/1]). + +%%% HTTP 1.1 tests +-export([ip_host/1, ip_chunked/1, ip_expect/1, ip_range/1, + ip_if_test/1, ip_http_trace/1, ip_http1_1_head/1, + ip_mod_cgi_chunked_encoding_test/1]). + +%%% HTTP 1.0 tests +-export([ip_head_1_0/1, ip_get_1_0/1, ip_post_1_0/1]). + +%%% HTTP 0.9 tests +-export([ip_get_0_9/1]). + +%%% Ticket tests +-export([ticket_5775/1,ticket_5865/1,ticket_5913/1,ticket_6003/1, + ticket_7304/1]). + +%%% Misc +-export([ipv6_hostname/1, ipv6_address/1]). + +%% Help functions +-export([cleanup_mnesia/0, setup_mnesia/0, setup_mnesia/1]). + +-define(IP_PORT, 8898). +-define(SSL_PORT, 8899). +-define(MAX_HEADER_SIZE, 256). +-define(IPV6_LOCAL_HOST, "0:0:0:0:0:0:0:1"). + +%% Minutes before failed auths timeout. +-define(FAIL_EXPIRE_TIME,1). + +%% Seconds before successful auths timeout. +-define(AUTH_TIMEOUT,5). + +-record(httpd_user, {user_name, password, user_data}). +-record(httpd_group,{group_name, userlist}). + + +%%-------------------------------------------------------------------- +%% all(Arg) -> [Doc] | [Case] | {skip, Comment} +%% Arg - doc | suite +%% Doc - string() +%% Case - atom() +%% Name of a test case function. +%% Comment - string() +%% Description: Returns documentation/test cases in this test suite +%% or a skip tuple if the platform is not supported. +%%-------------------------------------------------------------------- +all(doc) -> + ["Test the http server in the intes application."]; +all(suite) -> + [ + ip, + ssl, + http_1_1_ip, + http_1_0_ip, + http_0_9_ip, + %% ipv6, + tickets + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + io:format(user, "init_per_suite -> entry with" + "~n Config: ~p" + "~n", [Config]), + + PrivDir = ?config(priv_dir, Config), + SuiteTopDir = filename:join(PrivDir, ?MODULE), + case file:make_dir(SuiteTopDir) of + ok -> + ok; + {error, eexist} -> + ok; + Error -> + throw({error, {failed_creating_suite_top_dir, Error}}) + end, + + [{suite_top_dir, SuiteTopDir}, + {node, node()}, + {host, inets_test_lib:hostname()}, + {address, getaddr()} | Config]. + + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- + +end_per_suite(_Config) -> + %% SuiteTopDir = ?config(suite_top_dir, Config), + %% inets_test_lib:del_dirs(SuiteTopDir), + ok. + + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + NewConfig = init_per_testcase2(Case, Config), + init_per_testcase3(Case, NewConfig). + + +init_per_testcase2(Case, Config) -> + + io:format(user, "~w:init_per_testcase2(~w) -> entry with" + "~n Config: ~p" + "~n", [?MODULE, Case, Config]), + + IpNormal = integer_to_list(?IP_PORT) ++ ".conf", + IpHtacess = integer_to_list(?IP_PORT) ++ "htacess.conf", + SslNormal = integer_to_list(?SSL_PORT) ++ ".conf", + SslHtacess = integer_to_list(?SSL_PORT) ++ "htacess.conf", + + DataDir = ?config(data_dir, Config), + SuiteTopDir = ?config(suite_top_dir, Config), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n SuiteDir: ~p" + "~n DataDir: ~p" + "~n", [?MODULE, Case, SuiteTopDir, DataDir]), + + TcTopDir = filename:join(SuiteTopDir, Case), + ?line ok = file:make_dir(TcTopDir), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n TcTopDir: ~p" + "~n", [?MODULE, Case, TcTopDir]), + + DataSrc = filename:join([DataDir, "server_root"]), + ServerRoot = filename:join([TcTopDir, "server_root"]), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n DataSrc: ~p" + "~n ServerRoot: ~p" + "~n", [?MODULE, Case, DataSrc, ServerRoot]), + + ok = file:make_dir(ServerRoot), + ok = file:make_dir(filename:join([TcTopDir, "logs"])), + + NewConfig = [{tc_top_dir, TcTopDir}, {server_root, ServerRoot} | Config], + + io:format(user, "~w:init_per_testcase2(~w) -> " + "copy DataSrc to ServerRoot~n", + [?MODULE, Case]), + + inets_test_lib:copy_dirs(DataSrc, ServerRoot), + + io:format(user, "~w:init_per_testcase2(~w) -> fix cgi~n", + [?MODULE, Case]), + EnvCGI = filename:join([ServerRoot, "cgi-bin", "printenv.sh"]), + {ok, FileInfo} = file:read_file_info(EnvCGI), + ok = file:write_file_info(EnvCGI, + FileInfo#file_info{mode = 8#00755}), + + EchoCGI = case test_server:os_type() of + {win32, _} -> + "cgi_echo.exe"; + _ -> + "cgi_echo" + end, + CGIDir = filename:join([ServerRoot, "cgi-bin"]), + inets_test_lib:copy_file(EchoCGI, DataDir, CGIDir), + NewEchoCGI = filename:join([CGIDir, EchoCGI]), + {ok, FileInfo1} = file:read_file_info(NewEchoCGI), + ok = file:write_file_info(NewEchoCGI, + FileInfo1#file_info{mode = 8#00755}), + + %% To be used by IP test cases + io:format(user, "~w:init_per_testcase2(~w) -> ip testcase setups~n", + [?MODULE, Case]), + create_config([{port, ?IP_PORT}, {sock_type, ip_comm} | NewConfig], + normal_acess, IpNormal), + create_config([{port, ?IP_PORT}, {sock_type, ip_comm} | NewConfig], + mod_htaccess, IpHtacess), + + %% To be used by SSL test cases + io:format(user, "~w:init_per_testcase2(~w) -> ssl testcase setups~n", + [?MODULE, Case]), + create_config([{port, ?SSL_PORT}, {sock_type, ssl} | NewConfig], + normal_acess, SslNormal), + create_config([{port, ?SSL_PORT}, {sock_type, ssl} | NewConfig], + mod_htaccess, SslHtacess), + + %% To be used by IPv6 test cases. Case-clause is so that + %% you can do ts:run(inets, httpd_SUITE,+set +echo ^^^ + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh new file mode 100755 index 0000000000..de81de9bde --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Content-type: text/html" +echo "" +echo "
" +env +echo "" \ No newline at end of file diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf b/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf new file mode 100644 index 0000000000..48e66f0114 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf @@ -0,0 +1,79 @@ +Port 8080 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin jocke@erix.ericsson.se +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8080 +TransferLog logs/access_log_8080 +SecurityLog logs/security_log_8080 +ErrorDiskLog logs/error_disk_log_8080 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8080 +TransferDiskLogSize 200000 10 +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 +MaxClients 50 +#KeepAlive 5 +#KeepAliveTimeout 10 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +
Include /misc/friedrich.html: + +
Include /misc/not_defined.html: +
Include misc/friedrich.html: + +
Include not_defined.html: + +
DOCUMENT_NAME: +
DOCUMENT_URI: +
QUERY_STRING_UNESCAPED: +
DATE_LOCAL: +
DATE_GMT: +
LAST_MODIFIED: +
NOT_DEFINED: + +
Size of index.html: +
Size of not_defined.html: + +
Size of /misc/friedrich.html: +
Size of /misc/not_defined.html: + +
Last modification of index.html: +
Last modification of not_defined.html: +
Last modification of /misc/friedrich.html: +
Last modification of /misc/not_defined.html: + + + + + + + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html @@ -0,0 +1,10 @@ + +
+DOCUMENT_NAME: + +
DOCUMENT_URI: + +
QUERY_STRING_UNESCAPED: + +
DATE_LOCAL: + +
DATE_GMT: + +
LAST_MODIFIED: + +
NOT_DEFINED: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml new file mode 100644 index 0000000000..97333da898 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml @@ -0,0 +1,30 @@ + +
++ ++ +
+ +
+ +
+ +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml new file mode 100644 index 0000000000..d54c36fe50 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml @@ -0,0 +1,29 @@ + +
+Last modification of index.html: + +
Last modification of not_defined.html: + +
Last modification of /misc/friedrich.html: + +
Last modification of /misc/not_defined.html: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml new file mode 100644 index 0000000000..570ee9cf6d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml @@ -0,0 +1,29 @@ + +
+Size of index.html: + +
Size of not_defined.html: + +
Size of /misc/friedrich.html: + +
Size of /misc/not_defined.html: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml new file mode 100644 index 0000000000..529aad0437 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml @@ -0,0 +1,33 @@ + +
+Include /misc/friedrich.html: + + +
Include /misc/not_defined.html: + + +
Include misc/friedrich.html: + + +
Include not_defined.html: + + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html new file mode 100644 index 0000000000..cfdc9f9ab7 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html @@ -0,0 +1,25 @@ + +
+This document is only used for test of illegal last-modified date.
+ + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html new file mode 100644 index 0000000000..d7953d5df4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html @@ -0,0 +1,7 @@ +
+Talking much about oneself can also be a means to conceal oneself.
+-- Friedrich Nietzsche
+
+
+
Nested Include: + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html new file mode 100644 index 0000000000..506064bf04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html @@ -0,0 +1,4 @@ +
+What excuses stand in your way? How can you eliminate them?
+-- Roger von Oech
+
diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html
new file mode 100644
index 0000000000..8c17451f91
--- /dev/null
+++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html
@@ -0,0 +1 @@
+
diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html
new file mode 100644
index 0000000000..a6e8a35a04
--- /dev/null
+++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html
@@ -0,0 +1,10 @@
+
+
+set +echo ^^^ + + diff --git a/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh new file mode 100755 index 0000000000..de81de9bde --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Content-type: text/html" +echo "" +echo "
" +env +echo "" \ No newline at end of file diff --git a/lib/inets/test/httpd_test_data/server_root/conf/8080.conf b/lib/inets/test/httpd_test_data/server_root/conf/8080.conf new file mode 100644 index 0000000000..48e66f0114 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/8080.conf @@ -0,0 +1,79 @@ +Port 8080 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin jocke@erix.ericsson.se +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8080 +TransferLog logs/access_log_8080 +SecurityLog logs/security_log_8080 +ErrorDiskLog logs/error_disk_log_8080 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8080 +TransferDiskLogSize 200000 10 +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 +MaxClients 50 +#KeepAlive 5 +#KeepAliveTimeout 10 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +
Include /misc/friedrich.html: + +
Include /misc/not_defined.html: +
Include misc/friedrich.html: + +
Include not_defined.html: + +
DOCUMENT_NAME: +
DOCUMENT_URI: +
QUERY_STRING_UNESCAPED: +
DATE_LOCAL: +
DATE_GMT: +
LAST_MODIFIED: +
NOT_DEFINED: + +
Size of index.html: +
Size of not_defined.html: + +
Size of /misc/friedrich.html: +
Size of /misc/not_defined.html: + +
Last modification of index.html: +
Last modification of not_defined.html: +
Last modification of /misc/friedrich.html: +
Last modification of /misc/not_defined.html: + + + + + + + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html @@ -0,0 +1,10 @@ + +
+DOCUMENT_NAME: + +
DOCUMENT_URI: + +
QUERY_STRING_UNESCAPED: + +
DATE_LOCAL: + +
DATE_GMT: + +
LAST_MODIFIED: + +
NOT_DEFINED: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml new file mode 100644 index 0000000000..97333da898 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml @@ -0,0 +1,30 @@ + +
++ ++ +
+ +
+ +
+ +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml new file mode 100644 index 0000000000..d54c36fe50 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml @@ -0,0 +1,29 @@ + +
+Last modification of index.html: + +
Last modification of not_defined.html: + +
Last modification of /misc/friedrich.html: + +
Last modification of /misc/not_defined.html: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml new file mode 100644 index 0000000000..570ee9cf6d --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml @@ -0,0 +1,29 @@ + +
+Size of index.html: + +
Size of not_defined.html: + +
Size of /misc/friedrich.html: + +
Size of /misc/not_defined.html: + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml new file mode 100644 index 0000000000..529aad0437 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml @@ -0,0 +1,33 @@ + +
+Include /misc/friedrich.html: + + +
Include /misc/not_defined.html: + + +
Include misc/friedrich.html: + + +
Include not_defined.html: + + +
[Back] + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/index.html b/lib/inets/test/httpd_test_data/server_root/htdocs/index.html new file mode 100644 index 0000000000..cfdc9f9ab7 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/index.html @@ -0,0 +1,25 @@ + +
+This document is only used for test of illegal last-modified date.
+ + + + + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html new file mode 100644 index 0000000000..d7953d5df4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html @@ -0,0 +1,7 @@ +
+Talking much about oneself can also be a means to conceal oneself.
+-- Friedrich Nietzsche
+
+
+
Nested Include: + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html new file mode 100644 index 0000000000..506064bf04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html @@ -0,0 +1,4 @@ +
+What excuses stand in your way? How can you eliminate them?
+-- Roger von Oech
+
diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html
new file mode 100644
index 0000000000..8c17451f91
--- /dev/null
+++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html
@@ -0,0 +1 @@
+
diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html
new file mode 100644
index 0000000000..a6e8a35a04
--- /dev/null
+++ b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html
@@ -0,0 +1,10 @@
+
+