~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to lib/inets/src/http_server/httpd_util.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%%<copyright>
2
 
%% <year>1997-2008</year>
3
 
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
 
%%</copyright>
5
 
%%<legalnotice>
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
 
5
%% 
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/.
11
 
%%
 
11
%% 
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.
 
16
%% 
 
17
%% %CopyrightEnd%
16
18
%%
17
 
%% The Initial Developer of the Original Code is Ericsson AB.
18
 
%%</legalnotice>
19
19
%%
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").
37
37
 
38
 
-deprecated([{key1search, 2, next_major_release},
39
 
             {key1search, 3, next_major_release}
40
 
            ]).
41
 
 
 
38
ip_address({_,_,_,_} = Address) ->
 
39
    {ok, Address};
 
40
ip_address({_,_,_,_,_,_,_,_} = Address) ->
 
41
    {ok, 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);
46
 
        {ok, IPAddr} ->
47
 
            {ok, IPAddr};
48
 
        _ ->
49
 
            inet:getaddr(Host, inet) 
50
 
    end.
51
 
 
52
 
%% key1search
53
 
 
54
 
key1search(TupleList,Key) ->
55
 
    key1search(TupleList,Key,undefined).
56
 
 
57
 
key1search(TupleList,Key,Undefined) ->
58
 
    case lists:keysearch(Key,1,TupleList) of
59
 
        {value,{Key,Value}} ->
60
 
            Value;
61
 
        false ->
62
 
            Undefined
63
 
    end.
 
43
    Inet = case gen_tcp:listen(0, [inet6]) of
 
44
               {ok, Dummyport} ->
 
45
                   gen_tcp:close(Dummyport),
 
46
                   inet6;
 
47
               _ ->
 
48
                   inet
 
49
           end,
 
50
    inet:getaddr(Host, Inet).
64
51
 
65
52
%% lookup
66
53