diff --git a/README b/README index 3f0b41a..f12b998 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -$Id: README,v 1.9 2007/04/20 00:36:29 chandrusf Exp $ +$Id: README,v 1.10 2007/06/28 22:29:00 chandrusf Exp $ ibrowse is a HTTP client. The following are a list of features. - RFC2616 compliant (AFAIK) @@ -22,6 +22,9 @@ Comments to : Chandrashekhar.Mullaparthi@t-mobile.co.uk CONTRIBUTIONS & CHANGE HISTORY ============================== +28-06-2007 - Added host_header option to enable connection to secure sites + via stunnel + 20-04-2007 - Geoff Cant sent a patch to remove URL encoding for digits in ibrowse_lib:url_encode/1. ibrowse had a dependency on the inets application because the diff --git a/doc/ibrowse.html b/doc/ibrowse.html index e294032..e8f9a69 100644 --- a/doc/ibrowse.html +++ b/doc/ibrowse.html @@ -8,8 +8,11 @@

Module ibrowse

The ibrowse application implements an HTTP 1.1 client. +

Copyright © 2005-2007 Chandrashekhar Mullaparthi

+

Version: 1.2.7

Behaviours: gen_server.

+

Authors: Chandrashekhar Mullaparthi (chandrashekhar dot mullaparthi at gmail dot com).

Description

The ibrowse application implements an HTTP 1.1 client. This module implements the API of the HTTP client. There is one named @@ -136,10 +139,18 @@ send_req/4, send_req/5, send_req/6.

send_req/5

send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response() -

+

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. +
+

The host_header is useful in the case where ibrowse is + connecting to a component such as stunnel 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 Host header in + the request.

send_req/6

send_req(Url, Headers::headerList(), Method::method(), Body::body(), Options::optionList(), Timeout) -> response() diff --git a/src/ibrowse.erl b/src/ibrowse.erl index 231974c..4cffcc5 100644 --- a/src/ibrowse.erl +++ b/src/ibrowse.erl @@ -5,6 +5,9 @@ %%% %%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi %%%------------------------------------------------------------------- +%% @author Chandrashekhar Mullaparthi +%% @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 @@ -58,7 +61,7 @@ %% driver isn't actually used.

-module(ibrowse). --vsn('$Id: ibrowse.erl,v 1.3 2007/03/21 00:26:41 chandrusf Exp $ '). +-vsn('$Id: ibrowse.erl,v 1.4 2007/06/28 22:29:01 chandrusf Exp $ '). -behaviour(gen_server). %%-------------------------------------------------------------------- @@ -178,7 +181,16 @@ send_req(Url, Headers, Method, Body) -> %% @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. +%%
+%%

The host_header is useful in the case where ibrowse is +%% connecting to a component such as stunnel 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 Host header in +%% the request.

%% @spec send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response() %% optionList() = [option()] %% option() = {max_sessions, integer()} | @@ -199,6 +211,7 @@ send_req(Url, Headers, Method, Body) -> %% {save_response_to_file, boolean()} | %% {stream_to, process()} | %% {http_vsn, {MajorVsn, MinorVsn}} | +%% {host_header, string()} | %% {transfer_encoding, {chunked, ChunkSize}} %% %% process() = pid() | atom() diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl index 6ace2fb..a49e8c4 100644 --- a/src/ibrowse_http_client.erl +++ b/src/ibrowse_http_client.erl @@ -6,7 +6,7 @@ %%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi %%%------------------------------------------------------------------- -module(ibrowse_http_client). --vsn('$Id: ibrowse_http_client.erl,v 1.11 2007/04/20 00:36:30 chandrusf Exp $ '). +-vsn('$Id: ibrowse_http_client.erl,v 1.12 2007/06/28 22:29:01 chandrusf Exp $ '). -behaviour(gen_server). %%-------------------------------------------------------------------- @@ -459,12 +459,17 @@ send_req_1(Url, Headers, Method, Body, Options, Sock, State) -> 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 -> diff --git a/vsn.mk b/vsn.mk index e7438d4..7a6f0f9 100644 --- a/vsn.mk +++ b/vsn.mk @@ -1,2 +1,2 @@ -IBROWSE_VSN = 1.2.6 +IBROWSE_VSN = 1.2.7