aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client/httpc_internal.hrl
blob: e4127d992db499ca54907b67e33ad8ddf226fa34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
%%

-ifndef(httpc_internal_hrl).
-define(httpc_internal_hrl, true).

-include_lib("inets/src/inets_app/inets_internal.hrl").

-define(SERVICE, httpc).
-define(hcri(Label, Data), ?report_important(Label, ?SERVICE, Data)).
-define(hcrv(Label, Data), ?report_verbose(Label,   ?SERVICE, Data)).
-define(hcrd(Label, Data), ?report_debug(Label,     ?SERVICE, Data)).
-define(hcrt(Label, Data), ?report_trace(Label,     ?SERVICE, Data)).

-define(HTTP_REQUEST_TIMEOUT,    infinity).
-define(HTTP_REQUEST_CTIMEOUT,   ?HTTP_REQUEST_TIMEOUT).
-define(HTTP_PIPELINE_TIMEOUT,   0).
-define(HTTP_PIPELINE_LENGTH,    2).
-define(HTTP_MAX_TCP_SESSIONS,   2).
-define(HTTP_MAX_REDIRECTS,      4).
-define(HTTP_KEEP_ALIVE_TIMEOUT, 120000).
-define(HTTP_KEEP_ALIVE_LENGTH,  5).

%%% HTTP Client per request settings
-record(http_options,
	{
	  %% string() - "HTTP/1.1" | "HTTP/1.0" | "HTTP/0.9"
	  version, 

	  %% integer() | infinity - ms before a request times out
	  timeout = ?HTTP_REQUEST_TIMEOUT,  

	  %% bool() - true if auto redirect on 30x response
	  autoredirect = true, 

	  %% ssl socket options
	  ssl = [], 

	  %% {User, Password} = {string(), string()} 
	  proxy_auth, 

	  %% bool() - true if not strictly std compliant
	  relaxed = false, 

	  %% integer() - ms before a connect times out
	  connect_timeout = ?HTTP_REQUEST_CTIMEOUT,

	  %% bool() - Use %-encoding rfc 2396
	  url_encode

	 }
       ).

%%% HTTP Client per profile setting. 
-record(options, 
	{
	 proxy = {undefined, []}, % {{ProxyHost, ProxyPort}, [NoProxy]},
	 %% 0 means persistent connections are used without pipelining
	 pipeline_timeout      = ?HTTP_PIPELINE_TIMEOUT, 
	 max_pipeline_length   = ?HTTP_PIPELINE_LENGTH,
	 max_keep_alive_length = ?HTTP_KEEP_ALIVE_LENGTH,
	 keep_alive_timeout    = ?HTTP_KEEP_ALIVE_TIMEOUT, % Used when pipeline_timeout = 0
	 max_sessions          = ?HTTP_MAX_TCP_SESSIONS,
	 cookies               = disabled, % enabled | disabled | verify
	 verbose               = false,
	 ipfamily              = inet,    % inet | inet6 | inet6fb4
	 ip                    = default, % specify local interface
	 port                  = default, % specify local port
	 socket_opts           = []       % other socket options
	}
       ).

%%% All data associated to a specific HTTP request
-record(request,
	{
	  id,            % ref() - Request Id
	  from,          % pid() - Caller
	  redircount = 0,% Number of redirects made for this request
	  scheme,        % http | https 
	  address,       % ({Host,Port}) Destination Host and Port
	  path,          % string() - Path of parsed URL
	  pquery,        % string() - Rest of parsed URL
	  method,        % atom() - HTTP request Method
	  headers,       % #http_request_h{}
	  content,       % {ContentType, Body} - Current HTTP request
	  settings,      % #http_options{} - User defined settings
	  abs_uri,       % string() ex: "http://www.erlang.org"
	  userinfo,      % string() - optinal "<userinfo>@<host>:<port>"
	  stream,	 % boolean() - stream async reply?
	  headers_as_is, % boolean() - workaround for servers that does
			 % not honor the http standard, can also be used 
			 % for testing purposes.
	  started,       % integer() > 0 - When we started processing the 
			 % request
	  timer,         % undefined | ref()
	  socket_opts,   % undefined | [socket_option()]
	  ipv6_host_with_brackets % boolean()
	}
       ).               

-record(session,
	{
	  id,           % {{Host, Port}, HandlerPid}
	  client_close, % true | false
	  scheme,       % http (HTTP/TCP) | https (HTTP/SSL/TCP)
	  socket,       % Open socket, used by connection
	  socket_type,  % socket-type, used by connection
	  queue_length = 1, % Current length of pipeline or keep-alive queue  
	  type          % pipeline | keep_alive (wait for response before sending new request) 
	 }).

-record(http_cookie,
	{
	  domain,
	  domain_default = false,
	  name,
	  value,
	  comment,
	  max_age = session,
	  path, 
	  path_default = false,
	  secure = false,
	  version = "0" 
	 }).


%% -record(parsed_uri, 
%% 	{
%% 	  scheme, % http | https
%% 	  uinfo,  % string()
%% 	  host,   % string()
%% 	  port,   % integer()
%% 	  path,   % string()
%% 	  q       % query: string()
%% 	 }).


-endif. % -ifdef(httpc_internal_hrl).