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
|
%% ``Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% The Initial Developer of the Original Code is Mobile Arts AB
%% Portions created by Mobile Arts are Copyright 2002, Mobile Arts AB
%% All Rights Reserved.''
%%
%%
-define(HTTP_REQUEST_TIMEOUT, 5000).
-define(PIPELINE_LENGTH,3).
-define(OPEN_SESSIONS,400).
%%% FIXME! These definitions should probably be possible to defined via
%%% user settings
-define(MAX_REDIRECTS, 4).
%%% Note that if not persitent the connection can be closed immediately on a
%%% response, because new requests are not sent to this connection process.
%%% address, % ({Host,Port}) Destination Host and Port
-record(session,{
id, % (int) Session Id identifies session in http_manager
clientclose, % (bool) true if client requested "close" connection
scheme, % (atom) http (HTTP/TCP) or https (TCP/SSL/TCP)
socket, % (socket) Open socket, used by connection
pipeline=[], % (list) Sent requests, not yet taken care of by the
% associated http_responder.
quelength=1, % (int) Current length of pipeline (1 when created)
max_quelength% (int) Max pipeline length
}).
%%% [{Pid,RequestQue,QueLength},...] list where
%%% - RequestQue (implemented with a list) contains sent requests that
%%% has not yet received a response (pipelined) AND is not currently
%%% handled (awaiting data) by the session process.
%%% - QueLength is the length of this que, but
%%% Response headers
-record(res_headers,{
%%% --- Standard "General" headers
% cache_control,
connection,
% date,
% pragma,
% trailer,
transfer_encoding,
% upgrade,
% via,
% warning,
%%% --- Standard "Request" headers
% accept_ranges,
% age,
% etag,
location,
% proxy_authenticate,
retry_after,
% server,
% vary,
% www_authenticate,
%%% --- Standard "Entity" headers
% allow,
% content_encoding,
% content_language,
content_length="0",
% content_location,
% content_md5,
% content_range,
content_type,
% expires,
% last_modified,
other=[] % (list) Key/Value list with other headers
}).
%%% All data associated to a specific HTTP request
-record(request,{
id, % (int) Request Id
ref, % Caller specific
from, % (pid) Caller
redircount=0,% (int) Number of redirects made for this request
scheme, % (http|https) (HTTP/TCP) or (TCP/SSL/TCP) connection
address, % ({Host,Port}) Destination Host and Port
pathquery, % (string) Rest of parsed URL
method, % (atom) HTTP request Method
headers, % (list) Key/Value list with Headers
content, % ({ContentType,Body}) Current HTTP request
settings % (#client_settings{}) User defined settings
}).
-record(response,{
scheme, % (atom) http (HTTP/TCP) or https (TCP/SSL/TCP)
socket, % (socket) Open socket, used by connection
status,
http_version,
headers=#res_headers{},
body = <<>>
}).
%%% HTTP Client settings
-record(client_settings,{
timeout=?HTTP_REQUEST_TIMEOUT,
% (int) Milliseconds before a request times out
useproxy=false, % (bool) True if the proxy should be used
proxy=undefined, % (tuple) Parsed Proxy URL
noproxylist=[], % (list) List with hosts not requiring proxy
autoredirect=true, % (bool) True if automatic redirection on 30X
% responses.
max_sessions=?OPEN_SESSIONS,% (int) Max open sessions for any Adr,Port
max_quelength=?PIPELINE_LENGTH, % (int) Max pipeline length
% ssl=[{certfile,"/jb/server_root/ssl/ssl_client.pem"},
% {keyfile,"/jb/server_root/ssl/ssl_client.pem"},
% {verify,0}]
ssl=false % (list) SSL settings. A non-empty list enables SSL/TLS
% support in the HTTP client
}).
|