From: Chandru <cha...@us...> - 2007-06-28 22:29:18
|
Update of /cvsroot/jungerl/jungerl/lib/ibrowse/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18267/src Modified Files: ibrowse.erl ibrowse_http_client.erl Log Message: Added host_header option Index: ibrowse.erl =================================================================== RCS file: /cvsroot/jungerl/jungerl/lib/ibrowse/src/ibrowse.erl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ibrowse.erl 21 Mar 2007 00:26:41 -0000 1.3 +++ ibrowse.erl 28 Jun 2007 22:29:01 -0000 1.4 @@ -5,6 +5,9 @@ %%% %%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi <cha...@t-...> %%%------------------------------------------------------------------- +%% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com> +%% @copyright 2005-2007 Chandrashekhar Mullaparthi +%% @version 1.2.7 %% @doc The ibrowse application implements an HTTP 1.1 client. This %% module implements the API of the HTTP client. There is one named %% process called 'ibrowse' which acts as a load balancer. There is @@ -178,7 +181,16 @@ %% @doc Same as send_req/4. %% For a description of SSL Options, look in the ssl manpage. If the -%% HTTP Version to use is not specified, the default is 1.1 +%% HTTP Version to use is not specified, the default is 1.1. +%% <br/> +%% <p>The <code>host_header</code> is useful in the case where ibrowse is +%% connecting to a component such as <a +%% href="http://www.stunnel.org">stunnel</a> which then sets up a +%% secure connection to a webserver. In this case, the URL supplied to +%% ibrowse must have the stunnel host/port details, but that won't +%% make sense to the destination webserver. This option can then be +%% used to specify what should go in the <code>Host</code> header in +%% the request.</p> %% @spec send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response() %% optionList() = [option()] %% option() = {max_sessions, integer()} | @@ -199,6 +211,7 @@ %% {save_response_to_file, boolean()} | %% {stream_to, process()} | %% {http_vsn, {MajorVsn, MinorVsn}} | +%% {host_header, string()} | %% {transfer_encoding, {chunked, ChunkSize}} %% %% process() = pid() | atom() Index: ibrowse_http_client.erl =================================================================== RCS file: /cvsroot/jungerl/jungerl/lib/ibrowse/src/ibrowse_http_client.erl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- ibrowse_http_client.erl 20 Apr 2007 00:36:30 -0000 1.11 +++ ibrowse_http_client.erl 28 Jun 2007 22:29:01 -0000 1.12 @@ -459,12 +459,17 @@ port = Port, path = RelPath} = Url_1 = parse_url(Url), Headers_1 = add_auth_headers(Url_1, Options, Headers, State), - HostString = case Port of - 80 -> Host; - _ -> [Host, ":", integer_to_list(Port)] - end, + HostHeaderValue = case lists:keysearch(host_header, 1, Options) of + false -> + case Port of + 80 -> Host; + _ -> [Host, ":", integer_to_list(Port)] + end; + {value, {_, Host_h_val}} -> + Host_h_val + end, Req = make_request(Method, - [{"Host", HostString} | Headers_1], + [{"Host", HostHeaderValue} | Headers_1], AbsPath, RelPath, Body, Options, State#state.use_proxy), case get(my_trace_flag) of %%Avoid the binary operations if trace is not on... true -> |