Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

219 wiersze
12 KiB

18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
18 lat temu
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module ibrowse</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css">
  6. </head>
  7. <body bgcolor="white">
  8. <h1>Module ibrowse</h1>
  9. The ibrowse application implements an HTTP 1.1 client.
  10. <p>Copyright � 2005-2007 Chandrashekhar Mullaparthi</p>
  11. <ul><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>
  12. <p><b>Version:</b> 1.2.7</p>
  13. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  14. <p><b>Authors:</b> Chandrashekhar Mullaparthi (<a href="mailto:chandrashekhar dot mullaparthi at gmail dot com"><tt>chandrashekhar dot mullaparthi at gmail dot com</tt></a>).</p>
  15. <h2><a name="description">Description</a></h2><p>The ibrowse application implements an HTTP 1.1 client. This
  16. module implements the API of the HTTP client. There is one named
  17. process called 'ibrowse' which acts as a load balancer. There is
  18. one process to handle one TCP connection to a webserver
  19. (implemented in the module ibrowse_http_client). Multiple connections to a
  20. webserver are setup based on the settings for each webserver. The
  21. ibrowse process also determines which connection to pipeline a
  22. certain request on. The functions to call are send_req/3,
  23. send_req/4, send_req/5, send_req/6.</p>
  24. <p>Here are a few sample invocations.</p>
  25. <p><code>
  26. ibrowse:send_req("http://intranet/messenger/", [], get).
  27. <br><br>
  28. ibrowse:send_req("http://www.google.com/", [], get, [],
  29. [{proxy_user, "XXXXX"},
  30. {proxy_password, "XXXXX"},
  31. {proxy_host, "proxy"},
  32. {proxy_port, 8080}], 1000).
  33. <br><br>
  34. ibrowse:send_req("http://www.erlang.org/download/otp_src_R10B-3.tar.gz", [], get, [],
  35. [{proxy_user, "XXXXX"},
  36. {proxy_password, "XXXXX"},
  37. {proxy_host, "proxy"},
  38. {proxy_port, 8080},
  39. {save_response_to_file, true}], 1000).
  40. <br><br>
  41. ibrowse:set_dest("www.hotmail.com", 80, [{max_sessions, 10},
  42. {max_pipeline_size, 1}]).
  43. <br><br>
  44. ibrowse:send_req("http://www.erlang.org", [], head).
  45. <br><br>
  46. ibrowse:send_req("http://www.sun.com", [], options).
  47. <br><br>
  48. ibrowse:send_req("http://www.bbc.co.uk", [], trace).
  49. <br><br>
  50. ibrowse:send_req("http://www.google.com", [], get, [],
  51. [{stream_to, self()}]).
  52. </code></p>
  53. <p>A driver exists which implements URL encoding in C, but the
  54. speed achieved using only erlang has been good enough, so the
  55. driver isn't actually used.</p>
  56. <h2><a name="index">Function Index</a></h2>
  57. <table width="100%" border="1"><tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td/></tr>
  58. <tr><td valign="top"><a href="#finished_async_request-0">finished_async_request/0</a></td><td>Internal export.</td></tr>
  59. <tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td/></tr>
  60. <tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td/></tr>
  61. <tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td/></tr>
  62. <tr><td valign="top"><a href="#init-1">init/1</a></td><td/></tr>
  63. <tr><td valign="top"><a href="#reply-2">reply/2</a></td><td>Internal export.</td></tr>
  64. <tr><td valign="top"><a href="#send_req-3">send_req/3</a></td><td>This is the basic function to send a HTTP request.</td></tr>
  65. <tr><td valign="top"><a href="#send_req-4">send_req/4</a></td><td>Same as send_req/3.</td></tr>
  66. <tr><td valign="top"><a href="#send_req-5">send_req/5</a></td><td>Same as send_req/4.</td></tr>
  67. <tr><td valign="top"><a href="#send_req-6">send_req/6</a></td><td>Same as send_req/5.</td></tr>
  68. <tr><td valign="top"><a href="#set_dest-3">set_dest/3</a></td><td>Sets options for a destination.</td></tr>
  69. <tr><td valign="top"><a href="#shutting_down-0">shutting_down/0</a></td><td>Internal export.</td></tr>
  70. <tr><td valign="top"><a href="#start-0">start/0</a></td><td/></tr>
  71. <tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td/></tr>
  72. <tr><td valign="top"><a href="#stop-0">stop/0</a></td><td/></tr>
  73. <tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td/></tr>
  74. <tr><td valign="top"><a href="#trace_off-0">trace_off/0</a></td><td>Turn tracing off for the ibrowse process.</td></tr>
  75. <tr><td valign="top"><a href="#trace_off-2">trace_off/2</a></td><td>Turn tracing OFF for all connections to the specified HTTP
  76. server.</td></tr>
  77. <tr><td valign="top"><a href="#trace_on-0">trace_on/0</a></td><td>Turn tracing on for the ibrowse process.</td></tr>
  78. <tr><td valign="top"><a href="#trace_on-2">trace_on/2</a></td><td>Turn tracing on for all connections to the specified HTTP
  79. server.</td></tr>
  80. </table>
  81. <h2><a name="functions">Function Details</a></h2>
  82. <h3><a name="code_change-3">code_change/3</a></h3>
  83. <tt>code_change(OldVsn, State, Extra) -&gt; term()
  84. </tt>
  85. <h3><a name="finished_async_request-0">finished_async_request/0</a></h3>
  86. <tt>finished_async_request() -&gt; term()
  87. </tt><p>Internal export. Called by a HTTP connection process to
  88. indicate to the load balancing process (ibrowse) that an
  89. asynchronous request has finished processing.</p>
  90. <h3><a name="handle_call-3">handle_call/3</a></h3>
  91. <tt>handle_call(Req, From, State) -&gt; term()
  92. </tt>
  93. <h3><a name="handle_cast-2">handle_cast/2</a></h3>
  94. <tt>handle_cast(Msg, State) -&gt; term()
  95. </tt>
  96. <h3><a name="handle_info-2">handle_info/2</a></h3>
  97. <tt>handle_info(Info, State) -&gt; term()
  98. </tt>
  99. <h3><a name="init-1">init/1</a></h3>
  100. <tt>init(X1) -&gt; term()
  101. </tt>
  102. <h3><a name="reply-2">reply/2</a></h3>
  103. <tt>reply(OrigCaller, Reply) -&gt; term()
  104. </tt><p>Internal export. Called by a HTTP connection process to
  105. indicate to the load balancing process (ibrowse) that a synchronous
  106. request has finished processing.</p>
  107. <h3><a name="send_req-3">send_req/3</a></h3>
  108. <p><tt>send_req(Url::string(), Headers::<a href="#type-headerList">headerList()</a>, Method::<a href="#type-method">method()</a>) -&gt; <a href="#type-response">response()</a></tt>
  109. <ul><li><tt><a name="type-headerList">headerList()</a> = [{<a href="#type-header">header()</a>, <a href="#type-value">value()</a>}]</tt></li><li><tt><a name="type-header">header()</a> = atom() | string()</tt></li><li><tt><a name="type-value">value()</a> = term()</tt></li><li><tt><a name="type-method">method()</a> = get | post | head | options | put | delete | trace | mkcol | propfind | proppatch | lock | unlock | move | copy</tt></li><li><tt>Status = string()</tt></li><li><tt>ResponseHeaders = [<a href="#type-respHeader">respHeader()</a>]</tt></li><li><tt><a name="type-respHeader">respHeader()</a> = {<a href="#type-headerName">headerName()</a>, <a href="#type-headerValue">headerValue()</a>}</tt></li><li><tt><a name="type-headerName">headerName()</a> = string()</tt></li><li><tt><a name="type-headerValue">headerValue()</a> = string()</tt></li><li><tt><a name="type-response">response()</a> = {ok, Status, ResponseHeaders, ResponseBody} | {error, Reason}</tt></li><li><tt>ResponseBody = string()</tt></li><li><tt>Reason = term()</tt></li></ul></p>
  110. <p>This is the basic function to send a HTTP request.
  111. The Status return value indicates the HTTP status code returned by the webserver</p>
  112. <h3><a name="send_req-4">send_req/4</a></h3>
  113. <p><tt>send_req(Url, Headers, Method::<a href="#type-method">method()</a>, Body::<a href="#type-body">body()</a>) -&gt; <a href="#type-response">response()</a></tt>
  114. <ul><li><tt><a name="type-body">body()</a> = [] | string() | binary()</tt></li></ul></p>
  115. <p>Same as send_req/3.
  116. If a list is specified for the body it has to be a flat list.</p>
  117. <h3><a name="send_req-5">send_req/5</a></h3>
  118. <p><tt>send_req(Url::string(), Headers::<a href="#type-headerList">headerList()</a>, Method::<a href="#type-method">method()</a>, Body::<a href="#type-body">body()</a>, Options::<a href="#type-optionList">optionList()</a>) -&gt; <a href="#type-response">response()</a></tt>
  119. <ul><li><tt><a name="type-optionList">optionList()</a> = [<a href="#type-option">option()</a>]</tt></li><li><tt><a name="type-option">option()</a> = {max_sessions, integer()} | {max_pipeline_size, integer()} | {trace, <a href="#type-boolean">boolean()</a>} | {is_ssl, <a href="#type-boolean">boolean()</a>} | {ssl_options, [SSLOpt]} | {pool_name, atom()} | {proxy_host, string()} | {proxy_port, integer()} | {proxy_user, string()} | {proxy_password, string()} | {use_absolute_uri, <a href="#type-boolean">boolean()</a>} | {basic_auth, {<a href="#type-username">username()</a>, <a href="#type-password">password()</a>}} | {cookie, string()} | {content_length, integer()} | {content_type, string()} | {save_response_to_file, <a href="#type-boolean">boolean()</a>} | {stream_to, <a href="#type-process">process()</a>} | {http_vsn, {MajorVsn, MinorVsn}} | {host_header, string()} | {transfer_encoding, {chunked, ChunkSize}}</tt></li><li><tt><a name="type-process">process()</a> = pid() | atom()</tt></li><li><tt><a name="type-username">username()</a> = string()</tt></li><li><tt><a name="type-password">password()</a> = string()</tt></li><li><tt>SSLOpt = term()</tt></li><li><tt>ChunkSize = integer()</tt></li></ul></p>
  120. <p>Same as send_req/4.
  121. For a description of SSL Options, look in the ssl manpage. If the
  122. HTTP Version to use is not specified, the default is 1.1.
  123. <br>
  124. <p>The <code>host_header</code> is useful in the case where ibrowse is
  125. connecting to a component such as <a href="http://www.stunnel.org">stunnel</a> which then sets up a
  126. secure connection to a webserver. In this case, the URL supplied to
  127. ibrowse must have the stunnel host/port details, but that won't
  128. make sense to the destination webserver. This option can then be
  129. used to specify what should go in the <code>Host</code> header in
  130. the request.</p></p>
  131. <h3><a name="send_req-6">send_req/6</a></h3>
  132. <p><tt>send_req(Url, Headers::<a href="#type-headerList">headerList()</a>, Method::<a href="#type-method">method()</a>, Body::<a href="#type-body">body()</a>, Options::<a href="#type-optionList">optionList()</a>, Timeout) -&gt; <a href="#type-response">response()</a></tt>
  133. <ul><li><tt>Timeout = integer() | infinity</tt></li></ul></p>
  134. <p>Same as send_req/5.
  135. All timeout values are in milliseconds.</p>
  136. <h3><a name="set_dest-3">set_dest/3</a></h3>
  137. <p><tt>set_dest(Host::string(), Port::integer(), Opts::<a href="#type-opt_list">opt_list()</a>) -&gt; ok</tt>
  138. <ul><li><tt><a name="type-opt_list">opt_list()</a> = [opt]</tt></li><li><tt><a name="type-opt">opt()</a> = {max_sessions, integer()} | {max_pipeline_size, integer()} | {trace, <a href="#type-boolean">boolean()</a>}</tt></li></ul></p>
  139. <p>Sets options for a destination. If the options have not been
  140. set in the ibrowse.conf file, it can be set using this function
  141. before sending the first request to the destination. If not,
  142. defaults will be used. Entries in ibrowse.conf look like this.
  143. <code><br>
  144. {dest, Host, Port, MaxSess, MaxPipe, Options}.<br>
  145. where <br>
  146. Host = string(). "www.erlang.org" | "193.180.168.23"<br>
  147. Port = integer()<br>
  148. MaxSess = integer()<br>
  149. MaxPipe = integer()<br>
  150. Options = optionList() -- see options in send_req/5<br>
  151. </code></p>
  152. <h3><a name="shutting_down-0">shutting_down/0</a></h3>
  153. <tt>shutting_down() -&gt; term()
  154. </tt><p>Internal export. Called by a HTTP connection process to
  155. indicate to ibrowse that it is shutting down and further requests
  156. should not be sent it's way.</p>
  157. <h3><a name="start-0">start/0</a></h3>
  158. <tt>start() -&gt; term()
  159. </tt>
  160. <h3><a name="start_link-0">start_link/0</a></h3>
  161. <tt>start_link() -&gt; term()
  162. </tt>
  163. <h3><a name="stop-0">stop/0</a></h3>
  164. <tt>stop() -&gt; term()
  165. </tt>
  166. <h3><a name="terminate-2">terminate/2</a></h3>
  167. <tt>terminate(Reason, State) -&gt; term()
  168. </tt>
  169. <h3><a name="trace_off-0">trace_off/0</a></h3>
  170. <tt>trace_off() -&gt; term()
  171. </tt><p>Turn tracing off for the ibrowse process</p>
  172. <h3><a name="trace_off-2">trace_off/2</a></h3>
  173. <p><tt>trace_off(Host, Port) -&gt; term()</tt></p>
  174. <p>Turn tracing OFF for all connections to the specified HTTP
  175. server.</p>
  176. <h3><a name="trace_on-0">trace_on/0</a></h3>
  177. <tt>trace_on() -&gt; term()
  178. </tt><p>Turn tracing on for the ibrowse process</p>
  179. <h3><a name="trace_on-2">trace_on/2</a></h3>
  180. <p><tt>trace_on(Host, Port) -&gt; term()</tt>
  181. <ul><li><tt>Host = string()</tt></li><li><tt>Port = integer()</tt></li></ul></p>
  182. <p>Turn tracing on for all connections to the specified HTTP
  183. server. Host is whatever is specified as the domain name in the URL</p>
  184. </body>
  185. </html>