1%%% This code was developped by IDEALX (http://IDEALX.org/) and 2%%% contributors (their names can be found in the CONTRIBUTORS file). 3%%% Copyright (C) 2000-2001 IDEALX 4%%% 5%%% This program is free software; you can redistribute it and/or modify 6%%% it under the terms of the GNU General Public License as published by 7%%% the Free Software Foundation; either version 2 of the License, or 8%%% (at your option) any later version. 9%%% 10%%% This program is distributed in the hope that it will be useful, 11%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13%%% GNU General Public License for more details. 14%%% 15%%% You should have received a copy of the GNU General Public License 16%%% along with this program; if not, write to the Free Software 17%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18%%% 19%%% In addition, as a special exception, you have the permission to 20%%% link the code of this program with any library released under 21%%% the EPL license and distribute linked combinations including 22%%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23%%% Public License) is based on, is included in this exception. 24 25 26-vc('$Id$ '). 27-author('nicolas.niclausse@niclux.org'). 28 29%% use by the client to create the request 30-record(http_request, { 31 url, 32 version="1.1", % default is HTTP/1.1 33 host_header, % use for the 'Host:' header 34 get_ims_date, % used when the method is getims 35 cookie = [], 36 method = get, 37 content_type = [], 38 headers = [], 39 body = [], 40 id = 0, 41 user_agent, 42 oauth_consumer, 43 oauth_access_token, 44 oauth_access_secret, 45 oauth_url, 46 userid, % for www_authentication 47 passwd, % for www_authentication 48 auth_type, 49 digest_nonce, 50 digest_opaque, 51 digest_cnonce, 52 digest_nc, 53 digest_qop, 54 realm, 55 soap_action, % for SOAP support 56 tag, % for tagged requests 57 use_proxy = false 58 }). 59 60-record(url, 61 {scheme, %% http, https, ... 62 host, 63 port, %% undefined means use default (80 or 443) 64 path = [], 65 querypart = []}). 66 67%% use by the client process to store information about the current request during 68%% the parsing of the response, and for the whole session (user_agent and cookies) 69-record(http, {content_length= 0, % HTTP header: content length 70 body_size = 0, % current size of body, 71 chunk_toread = -1, % chunk data to be read (-1 = not chunked, -2 = not chunked, but last response was) 72 status = {none,none}, % HTTP resp. status :200, etc. 'none' 73 % if no current cnx. 74 close = false, % true if HTTP/1.0 or 'connection: close' 75 % has been received 76 partial=false, % true if headers are partially received 77 compressed={false,false}, % type of compression if body is compressed 78 cookie=[], %cookies of the current request 79 user_agent, 80 session_cookies = [] % Cookies of the session 81 }). 82 83 84-record(cookie,{ 85 key, 86 value, 87 quoted, 88 comment, 89 comment_url, 90 discard, 91 domain, 92 max_age, 93 expires, 94 path, 95 port, 96 secure, 97 version}). 98 99%% HTTP Protocol 100-define(GET, "GET"). 101-define(POST, "POST"). 102-define(PUT, "PUT"). 103-define(HEAD, "HEAD"). 104-define(DELETE, "DELETE"). 105-define(OPTIONS, "OPTIONS"). 106-define(PATCH, "PATCH"). 107-define(BODY_PARAM, "application/x-www-form-urlencoded"). 108 109-define(USER_AGENT, "Tsung"). 110-define(USER_AGENT_ERROR_MSG, "Total sum of user agents frequency is not equal to 100"). 111 112-define(MAX_HEADER_SIZE, 65536). % used for http_chunk:decode 113 114