Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

208 строки
11 KiB

20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
20 лет назад
18 лет назад
  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. <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>
  11. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  12. <h2><a name="description">Description</a></h2><p>The ibrowse application implements an HTTP 1.1 client. This
  13. module implements the API of the HTTP client. There is one named
  14. process called 'ibrowse' which acts as a load balancer. There is
  15. one process to handle one TCP connection to a webserver
  16. (implemented in the module ibrowse_http_client). Multiple connections to a
  17. webserver are setup based on the settings for each webserver. The
  18. ibrowse process also determines which connection to pipeline a
  19. certain request on. The functions to call are send_req/3,
  20. send_req/4, send_req/5, send_req/6.</p>
  21. <p>Here are a few sample invocations.</p>
  22. <p><code>
  23. ibrowse:send_req("http://intranet/messenger/", [], get).
  24. <br><br>
  25. ibrowse:send_req("http://www.google.com/", [], get, [],
  26. [{proxy_user, "XXXXX"},
  27. {proxy_password, "XXXXX"},
  28. {proxy_host, "proxy"},
  29. {proxy_port, 8080}], 1000).
  30. <br><br>
  31. ibrowse:send_req("http://www.erlang.org/download/otp_src_R10B-3.tar.gz", [], get, [],
  32. [{proxy_user, "XXXXX"},
  33. {proxy_password, "XXXXX"},
  34. {proxy_host, "proxy"},
  35. {proxy_port, 8080},
  36. {save_response_to_file, true}], 1000).
  37. <br><br>
  38. ibrowse:set_dest("www.hotmail.com", 80, [{max_sessions, 10},
  39. {max_pipeline_size, 1}]).
  40. <br><br>
  41. ibrowse:send_req("http://www.erlang.org", [], head).
  42. <br><br>
  43. ibrowse:send_req("http://www.sun.com", [], options).
  44. <br><br>
  45. ibrowse:send_req("http://www.bbc.co.uk", [], trace).
  46. <br><br>
  47. ibrowse:send_req("http://www.google.com", [], get, [],
  48. [{stream_to, self()}]).
  49. </code></p>
  50. <p>A driver exists which implements URL encoding in C, but the
  51. speed achieved using only erlang has been good enough, so the
  52. driver isn't actually used.</p>
  53. <h2><a name="index">Function Index</a></h2>
  54. <table width="100%" border="1"><tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td/></tr>
  55. <tr><td valign="top"><a href="#finished_async_request-0">finished_async_request/0</a></td><td>Internal export.</td></tr>
  56. <tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td/></tr>
  57. <tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td/></tr>
  58. <tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td/></tr>
  59. <tr><td valign="top"><a href="#init-1">init/1</a></td><td/></tr>
  60. <tr><td valign="top"><a href="#reply-2">reply/2</a></td><td>Internal export.</td></tr>
  61. <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>
  62. <tr><td valign="top"><a href="#send_req-4">send_req/4</a></td><td>Same as send_req/3.</td></tr>
  63. <tr><td valign="top"><a href="#send_req-5">send_req/5</a></td><td>Same as send_req/4.</td></tr>
  64. <tr><td valign="top"><a href="#send_req-6">send_req/6</a></td><td>Same as send_req/5.</td></tr>
  65. <tr><td valign="top"><a href="#set_dest-3">set_dest/3</a></td><td>Sets options for a destination.</td></tr>
  66. <tr><td valign="top"><a href="#shutting_down-0">shutting_down/0</a></td><td>Internal export.</td></tr>
  67. <tr><td valign="top"><a href="#start-0">start/0</a></td><td/></tr>
  68. <tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td/></tr>
  69. <tr><td valign="top"><a href="#stop-0">stop/0</a></td><td/></tr>
  70. <tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td/></tr>
  71. <tr><td valign="top"><a href="#trace_off-0">trace_off/0</a></td><td>Turn tracing off for the ibrowse process.</td></tr>
  72. <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
  73. server.</td></tr>
  74. <tr><td valign="top"><a href="#trace_on-0">trace_on/0</a></td><td>Turn tracing on for the ibrowse process.</td></tr>
  75. <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
  76. server.</td></tr>
  77. </table>
  78. <h2><a name="functions">Function Details</a></h2>
  79. <h3><a name="code_change-3">code_change/3</a></h3>
  80. <tt>code_change(OldVsn, State, Extra) -&gt; term()
  81. </tt>
  82. <h3><a name="finished_async_request-0">finished_async_request/0</a></h3>
  83. <tt>finished_async_request() -&gt; term()
  84. </tt><p>Internal export. Called by a HTTP connection process to
  85. indicate to the load balancing process (ibrowse) that an
  86. asynchronous request has finished processing.</p>
  87. <h3><a name="handle_call-3">handle_call/3</a></h3>
  88. <tt>handle_call(Req, From, State) -&gt; term()
  89. </tt>
  90. <h3><a name="handle_cast-2">handle_cast/2</a></h3>
  91. <tt>handle_cast(Msg, State) -&gt; term()
  92. </tt>
  93. <h3><a name="handle_info-2">handle_info/2</a></h3>
  94. <tt>handle_info(Info, State) -&gt; term()
  95. </tt>
  96. <h3><a name="init-1">init/1</a></h3>
  97. <tt>init(X1) -&gt; term()
  98. </tt>
  99. <h3><a name="reply-2">reply/2</a></h3>
  100. <tt>reply(OrigCaller, Reply) -&gt; term()
  101. </tt><p>Internal export. Called by a HTTP connection process to
  102. indicate to the load balancing process (ibrowse) that a synchronous
  103. request has finished processing.</p>
  104. <h3><a name="send_req-3">send_req/3</a></h3>
  105. <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>
  106. <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>
  107. <p>This is the basic function to send a HTTP request.
  108. The Status return value indicates the HTTP status code returned by the webserver</p>
  109. <h3><a name="send_req-4">send_req/4</a></h3>
  110. <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>
  111. <ul><li><tt><a name="type-body">body()</a> = [] | string() | binary()</tt></li></ul></p>
  112. <p>Same as send_req/3.
  113. If a list is specified for the body it has to be a flat list.</p>
  114. <h3><a name="send_req-5">send_req/5</a></h3>
  115. <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>
  116. <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}} | {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>
  117. <p>Same as send_req/4.
  118. For a description of SSL Options, look in the ssl manpage. If the
  119. HTTP Version to use is not specified, the default is 1.1</p>
  120. <h3><a name="send_req-6">send_req/6</a></h3>
  121. <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>
  122. <ul><li><tt>Timeout = integer() | infinity</tt></li></ul></p>
  123. <p>Same as send_req/5.
  124. All timeout values are in milliseconds.</p>
  125. <h3><a name="set_dest-3">set_dest/3</a></h3>
  126. <p><tt>set_dest(Host::string(), Port::integer(), Opts::<a href="#type-opt_list">opt_list()</a>) -&gt; ok</tt>
  127. <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>
  128. <p>Sets options for a destination. If the options have not been
  129. set in the ibrowse.conf file, it can be set using this function
  130. before sending the first request to the destination. If not,
  131. defaults will be used. Entries in ibrowse.conf look like this.
  132. <code><br>
  133. {dest, Host, Port, MaxSess, MaxPipe, Options}.<br>
  134. where <br>
  135. Host = string(). "www.erlang.org" | "193.180.168.23"<br>
  136. Port = integer()<br>
  137. MaxSess = integer()<br>
  138. MaxPipe = integer()<br>
  139. Options = optionList() -- see options in send_req/5<br>
  140. </code></p>
  141. <h3><a name="shutting_down-0">shutting_down/0</a></h3>
  142. <tt>shutting_down() -&gt; term()
  143. </tt><p>Internal export. Called by a HTTP connection process to
  144. indicate to ibrowse that it is shutting down and further requests
  145. should not be sent it's way.</p>
  146. <h3><a name="start-0">start/0</a></h3>
  147. <tt>start() -&gt; term()
  148. </tt>
  149. <h3><a name="start_link-0">start_link/0</a></h3>
  150. <tt>start_link() -&gt; term()
  151. </tt>
  152. <h3><a name="stop-0">stop/0</a></h3>
  153. <tt>stop() -&gt; term()
  154. </tt>
  155. <h3><a name="terminate-2">terminate/2</a></h3>
  156. <tt>terminate(Reason, State) -&gt; term()
  157. </tt>
  158. <h3><a name="trace_off-0">trace_off/0</a></h3>
  159. <tt>trace_off() -&gt; term()
  160. </tt><p>Turn tracing off for the ibrowse process</p>
  161. <h3><a name="trace_off-2">trace_off/2</a></h3>
  162. <p><tt>trace_off(Host, Port) -&gt; term()</tt></p>
  163. <p>Turn tracing OFF for all connections to the specified HTTP
  164. server.</p>
  165. <h3><a name="trace_on-0">trace_on/0</a></h3>
  166. <tt>trace_on() -&gt; term()
  167. </tt><p>Turn tracing on for the ibrowse process</p>
  168. <h3><a name="trace_on-2">trace_on/2</a></h3>
  169. <p><tt>trace_on(Host, Port) -&gt; term()</tt>
  170. <ul><li><tt>Host = string()</tt></li><li><tt>Port = integer()</tt></li></ul></p>
  171. <p>Turn tracing on for all connections to the specified HTTP
  172. server. Host is whatever is specified as the domain name in the URL</p>
  173. </body>
  174. </html>