ソースを参照

Added option headers_as_is

pull/16/head
Chandrashekhar Mullaparthi 15年前
コミット
dcee4cbe5d
4個のファイルの変更34行の追加18行の削除
  1. +3
    -1
      README
  2. +7
    -2
      src/ibrowse.erl
  3. +23
    -14
      src/ibrowse_http_client.erl
  4. +1
    -1
      vsn.mk

+ 3
- 1
README ファイルの表示

@ -18,12 +18,14 @@ ibrowse is available under two different licenses. LGPL and the BSD license.
Comments to : Chandrashekhar.Mullaparthi@gmail.com
Version : 1.5.5
Version : 1.5.6
Latest version : git://github.com/cmullaparthi/ibrowse.git
CONTRIBUTIONS & CHANGE HISTORY
==============================
08-11-2009 - * Added option headers_as_is
04-10-2009 - * Patch from Kostis Sagonas to cleanup some code and suppress
dialyzer warnings

+ 7
- 2
src/ibrowse.erl ファイルの表示

@ -226,12 +226,16 @@ send_req(Url, Headers, Method, Body) ->
%% request to complete will be 1000 milliseconds minus the time taken
%% for connection setup.
%% </li>
%% </ul>
%%
%% <li> The <code>socket_options</code> option can be used to set
%% specific options on the socket. The <code>{active, true | false | once}</code>
%% and <code>{packet_type, Packet_type}</code> will be filtered out by ibrowse. </li>
%%
%% <li> The <code>headers_as_is</code> option is to enable the caller
%% to send headers exactly as specified in the request without ibrowse
%% adding some of its own. Required for some picky servers apparently. </li>
%% </ul>
%%
%% @spec send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response()
%% optionList() = [option()]
%% option() = {max_sessions, integer()} |
@ -258,7 +262,8 @@ send_req(Url, Headers, Method, Body) ->
%% {inactivity_timeout, integer()} |
%% {connect_timeout, integer()} |
%% {socket_options, Sock_opts} |
%% {transfer_encoding, {chunked, ChunkSize}}
%% {transfer_encoding, {chunked, ChunkSize}} |
%% {headers_as_is, boolean()}
%%
%% stream_to() = process() | {process(), once}
%% process() = pid() | atom()

+ 23
- 14
src/ibrowse_http_client.erl ファイルの表示

@ -81,7 +81,8 @@ start_link(Args) ->
gen_server:start_link(?MODULE, Args, []).
stop(Conn_pid) ->
gen_server:call(Conn_pid, stop).
catch gen_server:call(Conn_pid, stop),
ok.
send_req(Conn_Pid, Url, Headers, Method, Body, Options, Timeout) ->
gen_server:call(
@ -527,8 +528,6 @@ send_req_1(From,
end;
send_req_1(From,
#url{abspath = AbsPath,
host = Host,
port = Port,
path = RelPath} = Url,
Headers, Method, Body, Options, Timeout,
#state{status = Status,
@ -565,18 +564,9 @@ send_req_1(From,
response_format = Resp_format,
from = From},
State_1 = State#state{reqs=queue:in(NewReq, State#state.reqs)},
Headers_1 = add_auth_headers(Url, Options, Headers, State_1),
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,
Headers_1 = maybe_modify_headers(Url, Options, Headers, State_1),
{Req, Body_1} = make_request(Method,
[{"Host", HostHeaderValue} | Headers_1],
Headers_1,
AbsPath, RelPath, Body, Options, State_1#state.use_proxy),
case get(my_trace_flag) of
true ->
@ -628,6 +618,25 @@ send_req_1(From,
{stop, normal, State_1}
end.
maybe_modify_headers(#url{host = Host, port = Port} = Url,
Options, Headers, State) ->
case get_value(headers_as_is, Options, false) of
false ->
Headers_1 = add_auth_headers(Url, Options, Headers, State),
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,
[{"Host", HostHeaderValue} | Headers_1];
true ->
Headers
end.
add_auth_headers(#url{username = User,
password = UPw},
Options,

+ 1
- 1
vsn.mk ファイルの表示

@ -1,2 +1,2 @@
IBROWSE_VSN = 1.5.5
IBROWSE_VSN = 1.5.6

読み込み中…
キャンセル
保存