diff options
author | Micael Karlberg <[email protected]> | 2010-01-13 16:18:47 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-01-13 16:18:47 +0000 |
commit | b327123e4da61ee2794aa473d357c37e7168d189 (patch) | |
tree | 2fd3de194f93abed00080ebfc06c825208897f52 /lib/inets/src | |
parent | 7ff3da1953b411d7c56f0334f774f951d7f88a00 (diff) | |
download | otp-b327123e4da61ee2794aa473d357c37e7168d189.tar.gz otp-b327123e4da61ee2794aa473d357c37e7168d189.tar.bz2 otp-b327123e4da61ee2794aa473d357c37e7168d189.zip |
OTP-8016, OTP-8056, OTP-8103, OTP-8106, OTP-8312, OTP-8315, OTP-8327, OTP-8349,
OTP-8351, OTP-8359 & OTP-8371.
Diffstat (limited to 'lib/inets/src')
21 files changed, 353 insertions, 920 deletions
diff --git a/lib/inets/src/http_client/Makefile b/lib/inets/src/http_client/Makefile index 23170f439f..628c91421f 100644 --- a/lib/inets/src/http_client/Makefile +++ b/lib/inets/src/http_client/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-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% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -29,17 +30,20 @@ include ../../vsn.mk VSN = $(INETS_VSN) + # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- MODULES = \ http \ - http_cookie \ + httpc \ + httpc_cookie \ httpc_handler \ httpc_manager \ httpc_sup \ @@ -55,20 +59,24 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- INETS_ERL_FLAGS += -I ../http_lib -I ../inets_app -pa ../../ebin -ERL_COMPILE_FLAGS += $(INETS_ERL_FLAGS)\ +ERL_COMPILE_FLAGS += $(INETS_ERL_FLAGS) \ $(INETS_FLAGS) \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' + + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -94,6 +102,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/http_client/http.erl b/lib/inets/src/http_client/http.erl index ce5d7723f0..7e1e90b50e 100644 --- a/lib/inets/src/http_client/http.erl +++ b/lib/inets/src/http_client/http.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2002-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% %% %% @@ -24,7 +24,6 @@ %%% - RFC 2818 HTTP Over TLS -module(http). --behaviour(inets_service). %% API -export([request/1, request/2, request/4, request/5, @@ -35,15 +34,6 @@ cookie_header/2, stream_next/1, default_profile/0]). -%% Behavior callbacks --export([start_standalone/1, start_service/1, - stop_service/1, services/0, service_info/1]). - --include("http_internal.hrl"). --include("httpc_internal.hrl"). - --define(DEFAULT_PROFILE, default). - %%%========================================================================= %%% API @@ -51,751 +41,75 @@ %%-------------------------------------------------------------------------- %% request(Url [, Profile]) -> -%% {ok, {StatusLine, Headers, Body}} | {error,Reason} -%% -%% Url - string() -%% Description: Calls request/4 with default values. +%% request(Method, Request, HTTPOptions, Options [, Profile]) %%-------------------------------------------------------------------------- -request(Url) -> - request(Url, default_profile()). - -request(Url, Profile) -> - request(get, {Url, []}, [], [], Profile). - - -%%-------------------------------------------------------------------------- -%% request(Method, Request, HTTPOptions, Options [, Profile]) -> -%% {ok, {StatusLine, Headers, Body}} | {ok, {Status, Body}} | -%% {ok, RequestId} | {error,Reason} | {ok, {saved_as, FilePath} -%% -%% Method - atom() = head | get | put | post | trace | options| delete -%% Request - {Url, Headers} | {Url, Headers, ContentType, Body} -%% Url - string() -%% HTTPOptions - [HttpOption] -%% HTTPOption - {timeout, Time} | {connect_timeout, Time} | -%% {ssl, SSLOptions} | {proxy_auth, {User, Password}} -%% Ssloptions = [SSLOption] -%% SSLOption = {verify, code()} | {depth, depth()} | {certfile, path()} | -%% {keyfile, path()} | {password, string()} | {cacertfile, path()} | -%% {ciphers, string()} -%% Options - [Option] -%% Option - {sync, Boolean} | {body_format, BodyFormat} | -%% {full_result, Boolean} | {stream, To} | -%% {headers_as_is, Boolean} -%% StatusLine = {HTTPVersion, StatusCode, ReasonPhrase}</v> -%% HTTPVersion = string() -%% StatusCode = integer() -%% ReasonPhrase = string() -%% Headers = [Header] -%% Header = {Field, Value} -%% Field = string() -%% Value = string() -%% Body = string() | binary() - HTLM-code -%% -%% Description: Sends a HTTP-request. The function can be both -%% syncronus and asynchronous in the later case the function will -%% return {ok, RequestId} and later on a message will be sent to the -%% calling process on the format {http, {RequestId, {StatusLine, -%% Headers, Body}}} or {http, {RequestId, {error, Reason}}} -%%-------------------------------------------------------------------------- +request(Url) -> httpc:request(Url). +request(Url, Profile) -> httpc:request(Url, Profile). request(Method, Request, HttpOptions, Options) -> - request(Method, Request, HttpOptions, Options, default_profile()). + httpc:request(Method, Request, HttpOptions, Options). +request(Method, Request, HttpOptions, Options, Profile) -> + httpc:request(Method, Request, HttpOptions, Options, Profile). -request(Method, {Url, Headers}, HTTPOptions, Options, Profile) - when (Method =:= options) orelse - (Method =:= get) orelse - (Method =:= head) orelse - (Method =:= delete) orelse - (Method =:= trace) -> - case http_uri:parse(Url) of - {error, Reason} -> - {error, Reason}; - ParsedUrl -> - handle_request(Method, Url, ParsedUrl, Headers, [], [], - HTTPOptions, Options, Profile) - end; - -request(Method, {Url,Headers,ContentType,Body}, HTTPOptions, Options, Profile) - when (Method =:= post) orelse (Method =:= put) -> - case http_uri:parse(Url) of - {error, Reason} -> - {error, Reason}; - ParsedUrl -> - handle_request(Method, Url, - ParsedUrl, Headers, ContentType, Body, - HTTPOptions, Options, Profile) - end. %%-------------------------------------------------------------------------- -%% request(RequestId) -> ok -%% RequestId - As returned by request/4 -%% -%% Description: Cancels a HTTP-request. +%% cancel_request(RequestId [, Profile]) %%------------------------------------------------------------------------- -cancel_request(RequestId) -> - cancel_request(RequestId, default_profile()). +cancel_request(RequestId) -> + httpc:cancel_request(RequestId). cancel_request(RequestId, Profile) -> - ok = httpc_manager:cancel_request(RequestId, profile_name(Profile)), - receive - %% If the request was allready fullfilled throw away the - %% answer as the request has been canceled. - {http, {RequestId, _}} -> - ok - after 0 -> - ok - end. - - -set_option(Key, Value) -> - set_option(Key, Value, default_profile()). - -set_option(Key, Value, Profile) -> - set_options([{Key, Value}], Profile). + httpc:cancel_request(RequestId, Profile). %%-------------------------------------------------------------------------- -%% set_options(Options [, Profile]) -> ok | {error, Reason} -%% Options - [Option] -%% Profile - atom() -%% Option - {proxy, {Proxy, NoProxy}} | {max_sessions, MaxSessions} | -%% {max_pipeline_length, MaxPipeline} | -%% {pipeline_timeout, PipelineTimeout} | {cookies, CookieMode} | -%% {ipfamily, IpFamily} -%% Proxy - {Host, Port} -%% NoProxy - [Domain | HostName | IPAddress] -%% MaxSessions, MaxPipeline, PipelineTimeout = integer() -%% CookieMode - enabled | disabled | verify -%% IpFamily - inet | inet6 | inet6fb4 -%% Description: Informs the httpc_manager of the new settings. +%% set_options(Options [, Profile]) +%% set_option(Key, Value [, Profile]) %%------------------------------------------------------------------------- + set_options(Options) -> - set_options(Options, default_profile()). + httpc:set_options(Options). set_options(Options, Profile) -> - case validate_options(Options) of - {ok, Opts} -> - try httpc_manager:set_options(Opts, profile_name(Profile)) of - Result -> - Result - catch - exit:{noproc, _} -> - {error, inets_not_started} - end; - {error, Reason} -> - {error, Reason} - end. + httpc:set_options(Options, Profile). + +set_option(Key, Value) -> + httpc:set_option(Key, Value). +set_option(Key, Value, Profile) -> + httpc:set_option(Key, Value, Profile). %%-------------------------------------------------------------------------- -%% verify_cookies(SetCookieHeaders, Url [, Profile]) -> ok | {error, reason} -%% -%% -%% Description: Store the cookies from <SetCookieHeaders> -%% in the cookie database -%% for the profile <Profile>. This function shall be used when the option -%% cookie is set to verify. +%% verify_cookies(SetCookieHeaders, Url [, Profile]) %%------------------------------------------------------------------------- -verify_cookies(SetCookieHeaders, Url) -> - verify_cookies(SetCookieHeaders, Url, default_profile()). +verify_cookies(SetCookieHeaders, Url) -> + httpc:store_cookies(SetCookieHeaders, Url). verify_cookies(SetCookieHeaders, Url, Profile) -> - {_, _, Host, Port, Path, _} = http_uri:parse(Url), - ProfileName = profile_name(Profile), - Cookies = http_cookie:cookies(SetCookieHeaders, Path, Host), - try httpc_manager:store_cookies(Cookies, {Host, Port}, ProfileName) of - _ -> - ok - catch - exit:{noproc, _} -> - {error, {not_started, Profile}} - end. + httpc:store_cookies(SetCookieHeaders, Url, Profile). + %%-------------------------------------------------------------------------- -%% cookie_header(Url [, Profile]) -> Header | {error, Reason} -%% -%% Description: Returns the cookie header that would be sent when making -%% a request to <Url>. +%% cookie_header(Url [, Profile]) %%------------------------------------------------------------------------- -cookie_header(Url) -> - cookie_header(Url, default_profile()). +cookie_header(Url) -> + httpc:cookie_header(Url). cookie_header(Url, Profile) -> - try httpc_manager:cookies(Url, profile_name(Profile)) of - Header -> - Header - catch - exit:{noproc, _} -> - {error, {not_started, Profile}} - end. - - -stream_next(Pid) -> - httpc_handler:stream_next(Pid). - -%%%======================================================================== -%%% Behavior callbacks -%%%======================================================================== -start_standalone(PropList) -> - case proplists:get_value(profile, PropList) of - undefined -> - {error, no_profile}; - Profile -> - Dir = - proplists:get_value(data_dir, PropList, only_session_cookies), - httpc_manager:start_link({Profile, Dir}, stand_alone) - end. - -start_service(Config) -> - httpc_profile_sup:start_child(Config). - -stop_service(Profile) when is_atom(Profile) -> - httpc_profile_sup:stop_child(Profile); -stop_service(Pid) when is_pid(Pid) -> - case service_info(Pid) of - {ok, [{profile, Profile}]} -> - stop_service(Profile); - Error -> - Error - end. - -services() -> - [{httpc, Pid} || {_, Pid, _, _} <- - supervisor:which_children(httpc_profile_sup)]. -service_info(Pid) -> - try [{ChildName, ChildPid} || - {ChildName, ChildPid, _, _} <- - supervisor:which_children(httpc_profile_sup)] of - Children -> - child_name2info(child_name(Pid, Children)) - catch - exit:{noproc, _} -> - {error, service_not_available} - end. - - -%%%======================================================================== -%%% Internal functions -%%%======================================================================== -handle_request(Method, Url, - {Scheme, UserInfo, Host, Port, Path, Query}, - Headers, ContentType, Body, - HTTPOptions0, Options, Profile) -> - - HTTPOptions = http_options(HTTPOptions0), - Sync = proplists:get_value(sync, Options, true), - NewHeaders = lists:map(fun({Key, Val}) -> - {http_util:to_lower(Key), Val} end, - Headers), - Stream = proplists:get_value(stream, Options, none), - case {Sync, Stream} of - {true, self} -> - {error, streaming_error}; - _ -> - RecordHeaders = header_record(NewHeaders, - #http_request_h{}, - Host, - HTTPOptions#http_options.version), - Request = #request{from = self(), - scheme = Scheme, - address = {Host,Port}, - path = Path, - pquery = Query, - method = Method, - headers = RecordHeaders, - content = {ContentType,Body}, - settings = HTTPOptions, - abs_uri = Url, - userinfo = UserInfo, - stream = Stream, - headers_as_is = headers_as_is(Headers, Options)}, - try httpc_manager:request(Request, profile_name(Profile)) of - {ok, RequestId} -> - handle_answer(RequestId, Sync, Options); - {error, Reason} -> - {error, Reason} - catch - error:{noproc, _} -> - {error, {not_started, Profile}} - end - end. - - -handle_answer(RequestId, false, _) -> - {ok, RequestId}; -handle_answer(RequestId, true, Options) -> - receive - {http, {RequestId, saved_to_file}} -> - {ok, saved_to_file}; - {http, {RequestId, Result = {_,_,_}}} -> - return_answer(Options, Result); - {http, {RequestId, {error, Reason}}} -> - {error, Reason} - end. - -return_answer(Options, {{"HTTP/0.9",_,_}, _, BinBody}) -> - Body = format_body(BinBody, Options), - {ok, Body}; - -return_answer(Options, {StatusLine, Headers, BinBody}) -> - - Body = format_body(BinBody, Options), - - case proplists:get_value(full_result, Options, true) of - true -> - {ok, {StatusLine, Headers, Body}}; - false -> - {_, Status, _} = StatusLine, - {ok, {Status, Body}} - end. - -format_body(BinBody, Options) -> - case proplists:get_value(body_format, Options, string) of - string -> - binary_to_list(BinBody); - _ -> - BinBody - end. + httpc:cookie_header(Url, Profile). -%% This options is a workaround for http servers that do not follow the -%% http standard and have case sensative header parsing. Should only be -%% used if there is no other way to communicate with the server or for -%% testing purpose. -headers_as_is(Headers, Options) -> - case proplists:get_value(headers_as_is, Options, false) of - false -> - []; - true -> - Headers - end. +%%-------------------------------------------------------------------------- +%% stream_next(Pid) +%%------------------------------------------------------------------------- -http_options(HttpOptions) -> - HttpOptionsDefault = http_options_default(), - http_options(HttpOptionsDefault, HttpOptions, #http_options{}). - -http_options([], [], Acc) -> - Acc; -http_options([], HttpOptions, Acc) -> - Fun = fun(BadOption) -> - Report = io_lib:format("Invalid option ~p ignored ~n", - [BadOption]), - error_logger:info_report(Report) - end, - lists:foreach(Fun, HttpOptions), - Acc; -http_options([{Tag, Default, Idx, Post} | Defaults], HttpOptions, Acc) -> - case lists:keysearch(Tag, 1, HttpOptions) of - {value, {Tag, Val0}} -> - case Post(Val0) of - {ok, Val} -> - Acc2 = setelement(Idx, Acc, Val), - HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), - http_options(Defaults, HttpOptions2, Acc2); - error -> - Report = io_lib:format("Invalid option ~p:~p ignored ~n", - [Tag, Val0]), - error_logger:info_report(Report), - HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), - http_options(Defaults, HttpOptions2, Acc) - end; - false -> - DefaultVal = - case Default of - {value, Val} -> - Val; - {field, DefaultIdx} -> - element(DefaultIdx, Acc) - end, - Acc2 = setelement(Idx, Acc, DefaultVal), - http_options(Defaults, HttpOptions, Acc2) - end. - -http_options_default() -> - VersionPost = - fun(Value) when is_atom(Value) -> - {ok, http_util:to_upper(atom_to_list(Value))}; - (Value) when is_list(Value) -> - {ok, http_util:to_upper(Value)}; - (_) -> - error - end, - TimeoutPost = fun(Value) when is_integer(Value) andalso (Value >= 0) -> - {ok, Value}; - (infinity = Value) -> - {ok, Value}; - (_) -> - error - end, - AutoRedirectPost = fun(Value) when (Value =:= true) orelse - (Value =:= false) -> - {ok, Value}; - (_) -> - error - end, - SslPost = fun(Value) when is_list(Value) -> - {ok, Value}; - (_) -> - error - end, - ProxyAuthPost = fun({User, Passwd} = Value) when is_list(User) andalso - is_list(Passwd) -> - {ok, Value}; - (_) -> - error - end, - RelaxedPost = fun(Value) when (Value =:= true) orelse - (Value =:= false) -> - {ok, Value}; - (_) -> - error - end, - ConnTimeoutPost = - fun(Value) when is_integer(Value) andalso (Value >= 0) -> - {ok, Value}; - (infinity = Value) -> - {ok, Value}; - (_) -> - error - end, - [ - {version, {value, "HTTP/1.1"}, #http_options.version, VersionPost}, - {timeout, {value, ?HTTP_REQUEST_TIMEOUT}, #http_options.timeout, TimeoutPost}, - {autoredirect, {value, true}, #http_options.autoredirect, AutoRedirectPost}, - {ssl, {value, []}, #http_options.ssl, SslPost}, - {proxy_auth, {value, undefined}, #http_options.proxy_auth, ProxyAuthPost}, - {relaxed, {value, false}, #http_options.relaxed, RelaxedPost}, - %% this field has to be *after* the timeout field (as that field is used for the default value) - {connect_timeout, {field, #http_options.timeout}, #http_options.connect_timeout, ConnTimeoutPost} - ]. - -validate_options(Options) -> - (catch validate_options(Options, [])). - -validate_options([], ValidateOptions) -> - {ok, lists:reverse(ValidateOptions)}; - -validate_options([{proxy, Proxy} = Opt| Tail], Acc) -> - validate_proxy(Proxy), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_sessions, Value} = Opt| Tail], Acc) -> - validate_max_sessions(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{keep_alive_timeout, Value} = Opt| Tail], Acc) -> - validate_keep_alive_timeout(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_keep_alive_length, Value} = Opt| Tail], Acc) -> - validate_max_keep_alive_length(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{pipeline_timeout, Value} = Opt| Tail], Acc) -> - validate_pipeline_timeout(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_pipeline_length, Value} = Opt| Tail], Acc) -> - validate_max_pipeline_length(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{cookies, Value} = Opt| Tail], Acc) -> - validate_cookies(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{ipfamily, Value} = Opt| Tail], Acc) -> - validate_ipfamily(Value), - validate_options(Tail, [Opt | Acc]); - -%% For backward compatibillity -validate_options([{ipv6, Value}| Tail], Acc) -> - NewValue = validate_ipv6(Value), - Opt = {ipfamily, NewValue}, - validate_options(Tail, [Opt | Acc]); - -validate_options([{ip, Value} = Opt| Tail], Acc) -> - validate_ip(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{port, Value} = Opt| Tail], Acc) -> - validate_port(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{verbose, Value} = Opt| Tail], Acc) -> - validate_verbose(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{_, _} = Opt| _], _Acc) -> - {error, {not_an_option, Opt}}. - - -validate_proxy({{ProxyHost, ProxyPort}, NoProxy} = Proxy) - when is_list(ProxyHost) andalso - is_integer(ProxyPort) andalso - is_list(NoProxy) -> - Proxy; -validate_proxy(BadProxy) -> - bad_option(proxy, BadProxy). - -validate_max_sessions(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_max_sessions(BadValue) -> - bad_option(max_sessions, BadValue). - -validate_keep_alive_timeout(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_keep_alive_timeout(infinity = Value) -> - Value; -validate_keep_alive_timeout(BadValue) -> - bad_option(keep_alive_timeout, BadValue). - -validate_max_keep_alive_length(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_max_keep_alive_length(BadValue) -> - bad_option(max_keep_alive_length, BadValue). - -validate_pipeline_timeout(Value) when is_integer(Value) -> - Value; -validate_pipeline_timeout(infinity = Value) -> - Value; -validate_pipeline_timeout(BadValue) -> - bad_option(pipeline_timeout, BadValue). - -validate_max_pipeline_length(Value) when is_integer(Value) -> - Value; -validate_max_pipeline_length(BadValue) -> - bad_option(max_pipeline_length, BadValue). - -validate_cookies(Value) - when ((Value =:= enabled) orelse - (Value =:= disabled) orelse - (Value =:= verify)) -> - Value; -validate_cookies(BadValue) -> - bad_option(cookies, BadValue). - -validate_ipv6(Value) when (Value =:= enabled) orelse (Value =:= disabled) -> - case Value of - enabled -> - inet6fb4; - disabled -> - inet - end; -validate_ipv6(BadValue) -> - bad_option(ipv6, BadValue). - -validate_ipfamily(Value) - when (Value =:= inet) orelse (Value =:= inet6) orelse (Value =:= inet6fb4) -> - Value; -validate_ipfamily(BadValue) -> - bad_option(ipfamily, BadValue). - -validate_ip(Value) - when is_tuple(Value) andalso ((size(Value) =:= 4) orelse (size(Value) =:= 8)) -> - Value; -validate_ip(BadValue) -> - bad_option(ip, BadValue). - -validate_port(Value) when is_integer(Value) -> - Value; -validate_port(BadValue) -> - bad_option(port, BadValue). - -validate_verbose(Value) - when ((Value =:= false) orelse - (Value =:= verbose) orelse - (Value =:= debug) orelse - (Value =:= trace)) -> - ok; -validate_verbose(BadValue) -> - bad_option(verbose, BadValue). - -bad_option(Option, BadValue) -> - throw({error, {bad_option, Option, BadValue}}). - - - -header_record([], RequestHeaders, Host, Version) -> - validate_headers(RequestHeaders, Host, Version); -header_record([{"cache-control", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'cache-control' = Val}, - Host, Version); -header_record([{"connection", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{connection = Val}, Host, - Version); -header_record([{"date", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{date = Val}, Host, - Version); -header_record([{"pragma", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{pragma = Val}, Host, - Version); -header_record([{"trailer", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{trailer = Val}, Host, - Version); -header_record([{"transfer-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'transfer-encoding' = Val}, - Host, Version); -header_record([{"upgrade", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{upgrade = Val}, Host, - Version); -header_record([{"via", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{via = Val}, Host, - Version); -header_record([{"warning", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{warning = Val}, Host, - Version); -header_record([{"accept", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{accept = Val}, Host, - Version); -header_record([{"accept-charset", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-charset' = Val}, - Host, Version); -header_record([{"accept-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-encoding' = Val}, - Host, Version); -header_record([{"accept-language", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-language' = Val}, - Host, Version); -header_record([{"authorization", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{authorization = Val}, - Host, Version); -header_record([{"expect", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{expect = Val}, Host, - Version); -header_record([{"from", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{from = Val}, Host, - Version); -header_record([{"host", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{host = Val}, Host, - Version); -header_record([{"if-match", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-match' = Val}, - Host, Version); -header_record([{"if-modified-since", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'if-modified-since' = Val}, - Host, Version); -header_record([{"if-none-match", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-none-match' = Val}, - Host, Version); -header_record([{"if-range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-range' = Val}, - Host, Version); - -header_record([{"if-unmodified-since", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-unmodified-since' - = Val}, Host, Version); -header_record([{"max-forwards", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'max-forwards' = Val}, - Host, Version); -header_record([{"proxy-authorization", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'proxy-authorization' - = Val}, Host, Version); -header_record([{"range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{range = Val}, Host, - Version); -header_record([{"referer", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{referer = Val}, Host, - Version); -header_record([{"te", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{te = Val}, Host, - Version); -header_record([{"user-agent", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'user-agent' = Val}, - Host, Version); -header_record([{"allow", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{allow = Val}, Host, - Version); -header_record([{"content-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-encoding' = Val}, - Host, Version); -header_record([{"content-language", Val} | Rest], RequestHeaders, - Host, Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-language' = Val}, - Host, Version); -header_record([{"content-length", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-length' = Val}, - Host, Version); -header_record([{"content-location", Val} | Rest], RequestHeaders, - Host, Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-location' = Val}, - Host, Version); -header_record([{"content-md5", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-md5' = Val}, - Host, Version); -header_record([{"content-range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-range' = Val}, - Host, Version); -header_record([{"content-type", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-type' = Val}, - Host, Version); -header_record([{"expires", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{expires = Val}, Host, - Version); -header_record([{"last-modified", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'last-modified' = Val}, - Host, Version); -header_record([{Key, Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{ - other = [{Key, Val} | - RequestHeaders#http_request_h.other]}, - Host, Version). +stream_next(Pid) -> + httpc:stream_next(Pid). -validate_headers(RequestHeaders = #http_request_h{te = undefined}, Host, - "HTTP/1.1" = Version) -> - validate_headers(RequestHeaders#http_request_h{te = ""}, Host, - "HTTP/1.1" = Version); -validate_headers(RequestHeaders = #http_request_h{host = undefined}, - Host, "HTTP/1.1" = Version) -> - validate_headers(RequestHeaders#http_request_h{host = Host}, Host, Version); -validate_headers(RequestHeaders, _, _) -> - RequestHeaders. +%%-------------------------------------------------------------------------- +%% default_profile() +%%------------------------------------------------------------------------- default_profile() -> - ?DEFAULT_PROFILE. - -profile_name(?DEFAULT_PROFILE) -> - httpc_manager; -profile_name(Pid) when is_pid(Pid) -> - Pid; -profile_name(Profile) -> - list_to_atom("httpc_manager_" ++ atom_to_list(Profile)). - -child_name2info(undefined) -> - {error, no_such_service}; -child_name2info(httpc_manager) -> - {ok, [{profile, default}]}; -child_name2info({http, Profile}) -> - {ok, [{profile, Profile}]}. - -child_name(_, []) -> - undefined; -child_name(Pid, [{Name, Pid} | _]) -> - Name; -child_name(Pid, [_ | Children]) -> - child_name(Pid, Children). - -%% d(F) -> -%% d(F, []). - -%% d(F, A) -> -%% d(get(dbg), F, A). - -%% d(true, F, A) -> -%% io:format(user, "~w:~w:" ++ F ++ "~n", [self(), ?MODULE | A]); -%% d(_, _, _) -> -%% ok. - + httpc:default_profile(). diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index e2ba66f730..df7d40a33e 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-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% %% @@ -132,8 +132,13 @@ result(Response = {{_,Code,_}, _, _}, Request) when (Code div 100) =:= 5 -> result(Response, Request) -> transparent(Response, Request). -send(To, Msg) -> - To ! {http, Msg}. +send(Receiver, Msg) when is_pid(Receiver) -> + Receiver ! {http, Msg}; +send(Receiver, Msg) when is_function(Receiver) -> + (catch Receiver(Msg)); +send({Module, Function, Args}, Msg) -> + (catch apply(Module, Function, [Msg | Args])). + %%%======================================================================== %%% Internal functions diff --git a/lib/inets/src/http_lib/Makefile b/lib/inets/src/http_lib/Makefile index 27e7ee65c5..7f4c92861c 100644 --- a/lib/inets/src/http_lib/Makefile +++ b/lib/inets/src/http_lib/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-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% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -29,10 +30,12 @@ include ../../vsn.mk VSN = $(INETS_VSN) + # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs @@ -50,10 +53,12 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS @@ -82,6 +87,7 @@ clean: docs: + # ---------------------------------------------------- # Release Target # ---------------------------------------------------- @@ -96,6 +102,8 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" + diff --git a/lib/inets/src/http_lib/http_chunk.erl b/lib/inets/src/http_lib/http_chunk.erl index cd20dce9d5..621bc68eae 100644 --- a/lib/inets/src/http_lib/http_chunk.erl +++ b/lib/inets/src/http_lib/http_chunk.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-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% %% %% Description: Implements chunked transfer encoding see RFC2616 section @@ -186,13 +186,6 @@ decode_data(ChunkSize, TotalChunk, Info = {MaxBodySize, BodySoFar, AccLength, MaxHeaderSize, Stream}) when ChunkSize =< size(TotalChunk) -> case TotalChunk of - %% Potential last chunk - <<_:ChunkSize/binary, ?CR, ?LF, "0">> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; - <<_:ChunkSize/binary, ?CR, ?LF, "0", ?CR>> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; - <<_:ChunkSize/binary, ?CR, ?LF>> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; %% Last chunk <<Data:ChunkSize/binary, ?CR, ?LF, "0", ";">> -> %% Note ignore_extensions will call decode_trailer/1 @@ -223,6 +216,10 @@ decode_data(ChunkSize, TotalChunk, NewBody, integer_to_list(AccLength)); %% There are more chunks, so here we go agin... + <<Data:ChunkSize/binary, ?CR, ?LF>> -> + {NewBody, NewStream} = + stream(<<BodySoFar/binary, Data/binary>>, Stream), + {?MODULE, decode_size, [<<>>, [], {MaxBodySize, NewBody, AccLength, MaxHeaderSize, NewStream}]}; <<Data:ChunkSize/binary, ?CR, ?LF, Rest/binary>> when (AccLength < MaxBodySize) or (MaxBodySize == nolimit) -> {NewBody, NewStream} = diff --git a/lib/inets/src/http_lib/http_transport.erl b/lib/inets/src/http_lib/http_transport.erl index 8100d7183a..27a950174f 100644 --- a/lib/inets/src/http_lib/http_transport.erl +++ b/lib/inets/src/http_lib/http_transport.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-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% %% % @@ -247,6 +247,7 @@ send(ip_comm, Socket, Message) -> send({ssl, _}, Socket, Message) -> ssl:send(Socket, Message). + %%------------------------------------------------------------------------- %% close(SocketType, Socket) -> ok | {error, Reason} %% SocketType = ip_comm | {ssl, _} diff --git a/lib/inets/src/http_lib/http_util.erl b/lib/inets/src/http_lib/http_util.erl index b03b780cf8..ddb58c7116 100644 --- a/lib/inets/src/http_lib/http_util.erl +++ b/lib/inets/src/http_lib/http_util.erl @@ -1,27 +1,33 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-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% %% %% -module(http_util). --export([to_upper/1, to_lower/1, convert_netscapecookie_date/1, +-export([ + to_upper/1, to_lower/1, + convert_netscapecookie_date/1, hexlist_to_integer/1, integer_to_hexlist/1, - convert_month/1, is_hostname/1]). + convert_month/1, + is_hostname/1, + timestamp/0, timeout/2 + ]). + %%%========================================================================= %%% Internal application API @@ -100,6 +106,21 @@ convert_month("Dec") -> 12. is_hostname(Dest) -> inet_parse:domain(Dest). + +timestamp() -> + {A,B,C} = os:timestamp(), + A*1000000000+B*1000+(C div 1000). + +timeout(Timeout, Started) -> + %% NewTimeout = Timeout - (timestamp() - Started), + case Timeout - (timestamp() - Started) of + NewTimeout when Timeout > 0 -> + NewTimeout; + _ -> + 0 + end. + + %%%======================================================================== %%% Internal functions %%%======================================================================== diff --git a/lib/inets/src/http_server/Makefile b/lib/inets/src/http_server/Makefile index 4bbd23df3f..ce1405011e 100644 --- a/lib/inets/src/http_server/Makefile +++ b/lib/inets/src/http_server/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-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% # # @@ -33,7 +33,7 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- @@ -92,7 +92,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' # ---------------------------------------------------- @@ -133,6 +133,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/http_server/httpd.erl b/lib/inets/src/http_server/httpd.erl index 554f162fc5..8fe54ccef6 100644 --- a/lib/inets/src/http_server/httpd.erl +++ b/lib/inets/src/http_server/httpd.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% %% @@ -358,7 +358,7 @@ foreach([KeyValue|Rest]) -> get_addr_and_port(ConfigFile) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), @@ -506,7 +506,7 @@ get_status(Addr,Port,Timeout) when is_integer(Port) -> end. do_reload_config(ConfigList, Mode) -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), diff --git a/lib/inets/src/http_server/httpd_conf.erl b/lib/inets/src/http_server/httpd_conf.erl index 9c93e2c5fe..3e498d1db7 100644 --- a/lib/inets/src/http_server/httpd_conf.erl +++ b/lib/inets/src/http_server/httpd_conf.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% %% @@ -864,17 +864,22 @@ load_traverse(Line, [Context|Contexts], [Module|Modules], NewContexts, {'EXIT', {undef, _}} -> ?hdrt("does not implement load", []), load_traverse(Line, Contexts, Modules, - [Context|NewContexts], ConfigList,yes); + [Context|NewContexts], ConfigList, yes); {'EXIT', Reason} -> error_logger:error_report({'EXIT', Reason}), load_traverse(Line, Contexts, Modules, [Context|NewContexts], ConfigList, State); + ok -> + ?hdrt("line processed", []), + load_traverse(Line, Contexts, Modules, + [Context|NewContexts], ConfigList, yes); + {ok, NewContext} -> ?hdrt("line processed", [{new_context, NewContext}]), load_traverse(Line, Contexts, Modules, - [NewContext|NewContexts], ConfigList,yes); + [NewContext|NewContexts], ConfigList, yes); {ok, NewContext, ConfigEntry} when is_tuple(ConfigEntry) -> ?hdrt("line processed", diff --git a/lib/inets/src/http_server/httpd_instance_sup.erl b/lib/inets/src/http_server/httpd_instance_sup.erl index 3b5464132c..0aaeb838c2 100644 --- a/lib/inets/src/http_server/httpd_instance_sup.erl +++ b/lib/inets/src/http_server/httpd_instance_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2001-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% %% %% @@ -37,7 +37,7 @@ %%% Internal Application API %%%========================================================================= start_link([{_, _}| _] = Config, AcceptTimeout, Debug) -> - case httpd_conf:validate_properties(Config) of + case (catch httpd_conf:validate_properties(Config)) of {ok, Config2} -> Address = proplists:get_value(bind_address, Config2), Port = proplists:get_value(port, Config2), @@ -66,7 +66,7 @@ start_link(ConfigFile, AcceptTimeout, Debug) -> start_link([{_, _}| _] = Config, AcceptTimeout, ListenInfo, Debug) -> - case httpd_conf:validate_properties(Config) of + case (catch httpd_conf:validate_properties(Config)) of {ok, Config2} -> Address = proplists:get_value(bind_address, Config2), Port = proplists:get_value(port, Config2), @@ -154,7 +154,7 @@ make_name(Address,Port) -> file_2_config(ConfigFile) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, ConfigList), Port = proplists:get_value(port, ConfigList), diff --git a/lib/inets/src/http_server/httpd_request.erl b/lib/inets/src/http_server/httpd_request.erl index ad2cc4bda3..8eee08e766 100644 --- a/lib/inets/src/http_server/httpd_request.erl +++ b/lib/inets/src/http_server/httpd_request.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-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% %% @@ -68,10 +68,11 @@ body_data(Headers, Body) -> {binary_to_list(BodyThisReq), Next} end. + %%------------------------------------------------------------------------- %% validate(Method, Uri, Version) -> ok | {error, {bad_request, Reason} | %% {error, {not_supported, {Method, Uri, Version}} -%% Method = "HEAD" | "GET" | "POST" | "TRACE" +%% Method = "HEAD" | "GET" | "POST" | "TRACE" | "PUT" | "DELETE" %% Uri = uri() %% Version = "HTTP/N.M" %% Description: Checks that HTTP-request-line is valid. @@ -84,6 +85,10 @@ validate("GET", Uri, "HTTP/0.9") -> validate_uri(Uri); validate("GET", Uri, "HTTP/1." ++ _N) -> validate_uri(Uri); +validate("PUT", Uri, "HTTP/1." ++ _N) -> + validate_uri(Uri); +validate("DELETE", Uri, "HTTP/1." ++ _N) -> + validate_uri(Uri); validate("POST", Uri, "HTTP/1." ++ _N) -> validate_uri(Uri); validate("TRACE", Uri, "HTTP/1." ++ N) when hd(N) >= $1 -> diff --git a/lib/inets/src/http_server/httpd_sup.erl b/lib/inets/src/http_server/httpd_sup.erl index fc41994727..3399f78b53 100644 --- a/lib/inets/src/http_server/httpd_sup.erl +++ b/lib/inets/src/http_server/httpd_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-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% %% %% @@ -169,7 +169,7 @@ httpd_child_spec([Value| _] = Config, AcceptTimeout, Debug) httpd_child_spec(ConfigFile, AcceptTimeout, Debug) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), diff --git a/lib/inets/src/http_server/mod_alias.erl b/lib/inets/src/http_server/mod_alias.erl index 7073f5405d..ec0a12242f 100644 --- a/lib/inets/src/http_server/mod_alias.erl +++ b/lib/inets/src/http_server/mod_alias.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% %% @@ -28,44 +28,51 @@ path/3]). -include("httpd.hrl"). +-include("httpd_internal.hrl"). -define(VMODULE,"ALIAS"). %% do -do(Info) -> - case proplists:get_value(status, Info#mod.data) of +do(#mod{data = Data} = Info) -> + ?hdrt("do", []), + case proplists:get_value(status, Data) of %% A status code has been generated! {_StatusCode, _PhraseArgs, _Reason} -> - {proceed,Info#mod.data}; + {proceed, Data}; %% No status code has been generated! undefined -> - case proplists:get_value(response, Info#mod.data) of + case proplists:get_value(response, Data) of %% No response has been generated! undefined -> do_alias(Info); %% A response has been generated or sent! _Response -> - {proceed, Info#mod.data} + {proceed, Data} end end. -do_alias(Info) -> - {ShortPath, Path, AfterPath} = - real_name(Info#mod.config_db, - Info#mod.request_uri, - httpd_util:multi_lookup(Info#mod.config_db,alias)), +do_alias(#mod{config_db = ConfigDB, + request_uri = ReqURI, + data = Data}) -> + {ShortPath, Path, AfterPath} = + real_name(ConfigDB, ReqURI, which_alias(ConfigDB)), + ?hdrt("real name", + [{request_uri, ReqURI}, + {short_path, ShortPath}, + {path, Path}, + {after_path, AfterPath}]), %% Relocate if a trailing slash is missing else proceed! LastChar = lists:last(ShortPath), case file:read_file_info(ShortPath) of - {ok, FileInfo} when FileInfo#file_info.type == directory, - LastChar /= $/ -> - ServerName = httpd_util:lookup(Info#mod.config_db, server_name), - Port = port_string(httpd_util:lookup(Info#mod.config_db,port, 80)), - URL = "http://" ++ ServerName ++ Port ++ - Info#mod.request_uri ++ "/", + {ok, FileInfo} when ((FileInfo#file_info.type =:= directory) andalso + (LastChar =/= $/)) -> + ?hdrt("directory and last-char is a /", []), + ServerName = which_server_name(ConfigDB), + Port = port_string( which_port(ConfigDB) ), + URL = "http://" ++ ServerName ++ Port ++ ReqURI ++ "/", ReasonPhrase = httpd_util:reason_phrase(301), - Message = httpd_util:message(301, URL, Info#mod.config_db), + Message = httpd_util:message(301, URL, ConfigDB), {proceed, [{response, {301, ["Location: ", URL, "\r\n" @@ -76,25 +83,26 @@ do_alias(Info) -> "<BODY>\n<H1>",ReasonPhrase, "</H1>\n", Message, "\n</BODY>\n</HTML>\n"]}}| - [{real_name, {Path, AfterPath}} | Info#mod.data]]}; + [{real_name, {Path, AfterPath}} | Data]]}; _NoFile -> - {proceed,[{real_name, {Path, AfterPath}} | Info#mod.data]} + {proceed, [{real_name, {Path, AfterPath}} | Data]} end. port_string(80) -> ""; port_string(Port) -> - ":"++integer_to_list(Port). + ":" ++ integer_to_list(Port). %% real_name real_name(ConfigDB, RequestURI, []) -> - DocumentRoot = httpd_util:lookup(ConfigDB, document_root, ""), + DocumentRoot = which_document_root(ConfigDB), RealName = DocumentRoot ++ RequestURI, {ShortPath, _AfterPath} = httpd_util:split_path(RealName), - {Path, AfterPath} = httpd_util:split_path(default_index(ConfigDB, - RealName)), + {Path, AfterPath} = + httpd_util:split_path(default_index(ConfigDB, RealName)), {ShortPath, Path, AfterPath}; + real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> case inets_regexp:match(RequestURI, "^" ++ FakeName) of {match, _, _} -> @@ -105,7 +113,7 @@ real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> httpd_util:split_path(default_index(ConfigDB, ActualName)), {ShortPath, Path, AfterPath}; nomatch -> - real_name(ConfigDB,RequestURI,Rest) + real_name(ConfigDB, RequestURI, Rest) end. %% real_script_name @@ -113,20 +121,21 @@ real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> real_script_name(_ConfigDB, _RequestURI, []) -> not_a_script; real_script_name(ConfigDB, RequestURI, [{FakeName,RealName} | Rest]) -> - case inets_regexp:match(RequestURI,"^"++FakeName) of + case inets_regexp:match(RequestURI, "^" ++ FakeName) of {match,_,_} -> - {ok,ActualName,_}=inets_regexp:sub(RequestURI,"^"++FakeName,RealName), - httpd_util:split_script_path(default_index(ConfigDB,ActualName)); + {ok, ActualName, _} = + inets_regexp:sub(RequestURI, "^" ++ FakeName, RealName), + httpd_util:split_script_path(default_index(ConfigDB, ActualName)); nomatch -> - real_script_name(ConfigDB,RequestURI,Rest) + real_script_name(ConfigDB, RequestURI, Rest) end. %% default_index default_index(ConfigDB, Path) -> case file:read_file_info(Path) of - {ok, FileInfo} when FileInfo#file_info.type == directory -> - DirectoryIndex = httpd_util:lookup(ConfigDB, directory_index, []), + {ok, FileInfo} when FileInfo#file_info.type =:= directory -> + DirectoryIndex = which_directory_index(ConfigDB), append_index(Path, DirectoryIndex); _ -> Path @@ -147,9 +156,9 @@ append_index(RealName, [Index | Rest]) -> path(Data, ConfigDB, RequestURI) -> case proplists:get_value(real_name, Data) of undefined -> - DocumentRoot = httpd_util:lookup(ConfigDB, document_root, ""), + DocumentRoot = which_document_root(ConfigDB), {Path, _AfterPath} = - httpd_util:split_path(DocumentRoot++RequestURI), + httpd_util:split_path(DocumentRoot ++ RequestURI), Path; {Path, _AfterPath} -> Path @@ -164,7 +173,7 @@ path(Data, ConfigDB, RequestURI) -> load("DirectoryIndex " ++ DirectoryIndex, []) -> {ok, DirectoryIndexes} = inets_regexp:split(DirectoryIndex," "), {ok,[], {directory_index, DirectoryIndexes}}; -load("Alias " ++ Alias,[]) -> +load("Alias " ++ Alias, []) -> case inets_regexp:split(Alias," ") of {ok, [FakeName, RealName]} -> {ok,[],{alias,{FakeName,RealName}}}; @@ -191,13 +200,13 @@ store({directory_index, Value} = Conf, _) when is_list(Value) -> end; store({directory_index, Value}, _) -> {error, {wrong_type, {directory_index, Value}}}; -store({alias, {Fake, Real}} = Conf, _) when is_list(Fake), - is_list(Real) -> +store({alias, {Fake, Real}} = Conf, _) + when is_list(Fake) andalso is_list(Real) -> {ok, Conf}; store({alias, Value}, _) -> {error, {wrong_type, {alias, Value}}}; -store({script_alias, {Fake, Real}} = Conf, _) when is_list(Fake), - is_list(Real) -> +store({script_alias, {Fake, Real}} = Conf, _) + when is_list(Fake) andalso is_list(Real) -> {ok, Conf}; store({script_alias, Value}, _) -> {error, {wrong_type, {script_alias, Value}}}. @@ -208,3 +217,21 @@ is_directory_index_list([Head | Tail]) when is_list(Head) -> is_directory_index_list(Tail); is_directory_index_list(_) -> false. + + +%% --------------------------------------------------------------------- + +which_alias(ConfigDB) -> + httpd_util:multi_lookup(ConfigDB, alias). + +which_server_name(ConfigDB) -> + httpd_util:lookup(ConfigDB, server_name). + +which_port(ConfigDB) -> + httpd_util:lookup(ConfigDB, port, 80). + +which_document_root(ConfigDB) -> + httpd_util:lookup(ConfigDB, document_root, ""). + +which_directory_index(ConfigDB) -> + httpd_util:lookup(ConfigDB, directory_index, []). diff --git a/lib/inets/src/http_server/mod_cgi.erl b/lib/inets/src/http_server/mod_cgi.erl index ab12a3b57b..33605b9698 100644 --- a/lib/inets/src/http_server/mod_cgi.erl +++ b/lib/inets/src/http_server/mod_cgi.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% %% @@ -335,6 +335,8 @@ script_elements(#mod{method = "GET"}, {PathInfo, QueryString}) -> [{query_string, QueryString}, {path_info, PathInfo}]; script_elements(#mod{method = "POST", entity_body = Body}, _) -> [{entity_body, Body}]; +script_elements(#mod{method = "PUT", entity_body = Body}, _) -> + [{entity_body, Body}]; script_elements(_, _) -> []. diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl index dd6f62ae2d..484d4b3fb4 100644 --- a/lib/inets/src/http_server/mod_esi.erl +++ b/lib/inets/src/http_server/mod_esi.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% %% @@ -249,7 +249,24 @@ erl(#mod{method = Method} = ModData, ESIBody, Modules) {proceed, [{status,{400, none, BadRequest}} | ModData#mod.data]} end; -erl(#mod{method = "POST", entity_body = Body} = ModData, ESIBody, Modules) -> +erl(#mod{request_uri = ReqUri, + method = "PUT", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed, [{status,{501,{"PUT", ReqUri, Version}, + ?NICE("Erl mechanism doesn't support method PUT")}}| + Data]}; + +erl(#mod{request_uri = ReqUri, + method = "DELETE", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"DELETE", ReqUri, Version}, + ?NICE("Erl mechanism doesn't support method DELETE")}}| + Data]}; + +erl(#mod{method = "POST", + entity_body = Body} = ModData, ESIBody, Modules) -> case httpd_util:split(ESIBody,":|%3A|/",2) of {ok,[ModuleName, Function]} -> generate_webpage(ModData, ESIBody, Modules, @@ -444,8 +461,26 @@ input_type([_First|Rest]) -> %%------------------------ Eval mechanism -------------------------------- -eval(#mod{request_uri = ReqUri, method = "POST", - http_version = Version, data = Data}, _ESIBody, _Modules) -> +eval(#mod{request_uri = ReqUri, + method = "PUT", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"PUT", ReqUri, Version}, + ?NICE("Eval mechanism doesn't support method PUT")}}| + Data]}; + +eval(#mod{request_uri = ReqUri, + method = "DELETE", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"DELETE", ReqUri, Version}, + ?NICE("Eval mechanism doesn't support method DELETE")}}| + Data]}; + +eval(#mod{request_uri = ReqUri, + method = "POST", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> {proceed,[{status,{501,{"POST", ReqUri, Version}, ?NICE("Eval mechanism doesn't support method POST")}}| Data]}; diff --git a/lib/inets/src/inets_app/Makefile b/lib/inets/src/inets_app/Makefile index 2dab99386a..33c9e34a3a 100644 --- a/lib/inets/src/inets_app/Makefile +++ b/lib/inets/src/inets_app/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-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% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -32,12 +33,13 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- + MODULES = \ inets_service \ inets \ @@ -49,7 +51,8 @@ HRL_FILES = inets_internal.hrl ERL_FILES = $(MODULES:%=%.erl) -TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) \ +TARGET_FILES= \ + $(MODULES:%=$(EBIN)/%.$(EMULATOR)) \ $(APP_TARGET) \ $(APPUP_TARGET) @@ -66,7 +69,7 @@ APPUP_TARGET = $(EBIN)/$(APPUP_FILE) # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' # ---------------------------------------------------- @@ -108,14 +111,15 @@ $(APPUP_TARGET): $(APPUP_SRC) ../../vsn.mk include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/src + $(INSTALL_DIR) $(RELSYSDIR)/src $(INSTALL_DATA) $(HRL_FILES) $(ERL_FILES) $(RELSYSDIR)/src - $(INSTALL_DIR) $(RELSYSDIR)/ebin + $(INSTALL_DIR) $(RELSYSDIR)/ebin $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/inets_app/inets.app.src b/lib/inets/src/inets_app/inets.app.src index 6524c3b19b..04f6365b98 100644 --- a/lib/inets/src/inets_app/inets.app.src +++ b/lib/inets/src/inets_app/inets.app.src @@ -1,19 +1,19 @@ %% This is an -*- erlang -*- file. %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-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% %% @@ -34,7 +34,8 @@ ftp_sup, %% HTTP client: - http, + http, %% Old client API module + httpc, %% New client API module httpc_handler, httpc_handler_sup, httpc_manager, @@ -42,7 +43,7 @@ httpc_request, httpc_response, httpc_sup, - http_cookie, + httpc_cookie, http_uri, %% Proably will by used by server also in the future diff --git a/lib/inets/src/inets_app/inets.appup.src b/lib/inets/src/inets_app/inets.appup.src index 0112a64239..2efa7ccb60 100644 --- a/lib/inets/src/inets_app/inets.appup.src +++ b/lib/inets/src/inets_app/inets.appup.src @@ -1,34 +1,31 @@ %% This is an -*- erlang -*- file. %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% 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% {"%VSN%", [ {"5.2", [ - {load_module, inets, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.3", [ - {load_module, httpd_response, soft_purge, soft_purge, []}, - {update, ftp, {advanced, upgrade_from_pre_5_12}, - soft_purge, soft_purge, []}, - {update, httpc_handler, soft, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.2", @@ -40,15 +37,12 @@ [ {"5.2", [ - {load_module, inets, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.3", [ - {load_module, httpd_response, soft_purge, soft_purge, []}, - {update, ftp, {advanced, downgrade_to_pre_5_12}, - soft_purge, soft_purge, []}, - {update, httpc_handler, soft, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.2", diff --git a/lib/inets/src/inets_app/inets.erl b/lib/inets/src/inets_app/inets.erl index 77cb14cc20..7e3f862ee7 100644 --- a/lib/inets/src/inets_app/inets.erl +++ b/lib/inets/src/inets_app/inets.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-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% %% %% @@ -522,9 +522,7 @@ change_pattern({Mod, Service, Pattern}) catch exit:{Where, Reason} -> {error, {Where, Reason}} - end; - _ -> - exit({bad_pattern, Pattern}) + end end, ok. @@ -728,7 +726,7 @@ call_service(Service, Call, Args) -> service_module(tftpd) -> tftp; service_module(httpc) -> - http; + httpc; service_module(ftpc) -> ftp; service_module(Service) -> diff --git a/lib/inets/src/tftp/Makefile b/lib/inets/src/tftp/Makefile index 63f70f7943..b4339da1e2 100644 --- a/lib/inets/src/tftp/Makefile +++ b/lib/inets/src/tftp/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-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% # # @@ -33,7 +33,8 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs @@ -53,10 +54,12 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS @@ -64,6 +67,8 @@ INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ ERL_COMPILE_FLAGS += $(INETS_FLAGS) \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' + + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -90,6 +95,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" |