Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

224 rindas
11 KiB

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