2
%% <year>1997-2008</year>
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
17
%% The Initial Developer of the Original Code is Ericsson AB.
20
20
-module(httpd_util).
21
-export([ip_address/1, key1search/2, key1search/3, lookup/2, lookup/3, multi_lookup/2,
21
-export([ip_address/1, lookup/2, lookup/3, multi_lookup/2,
22
22
lookup_mime/2, lookup_mime/3, lookup_mime_default/2,
23
23
lookup_mime_default/3, reason_phrase/1, message/3, rfc1123_date/0,
24
24
rfc1123_date/1, day/1, month/1, decode_hex/1,
35
35
-export([encode_hex/1]).
36
36
-include_lib("kernel/include/file.hrl").
38
-deprecated([{key1search, 2, next_major_release},
39
{key1search, 3, next_major_release}
38
ip_address({_,_,_,_} = Address) ->
40
ip_address({_,_,_,_,_,_,_,_} = Address) ->
42
42
ip_address(Host) ->
43
case (catch inet:getaddr(Host,inet6)) of
44
{ok, {0, 0, 0, 0, 0, 16#ffff, _, _}} ->
45
inet:getaddr(Host, inet);
49
inet:getaddr(Host, inet)
54
key1search(TupleList,Key) ->
55
key1search(TupleList,Key,undefined).
57
key1search(TupleList,Key,Undefined) ->
58
case lists:keysearch(Key,1,TupleList) of
59
{value,{Key,Value}} ->
43
Inet = case gen_tcp:listen(0, [inet6]) of
45
gen_tcp:close(Dummyport),
50
inet:getaddr(Host, Inet).