Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

451 lignes
26 KiB

il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
il y a 18 ans
  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" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  9. <hr>
  10. <h1>Module ibrowse</h1>
  11. <ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>The ibrowse application implements an HTTP 1.1 client.
  12. <p>Copyright � 2005-2010 Chandrashekhar Mullaparthi</p>
  13. <p><b>Version:</b> 2.0.0</p>
  14. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  15. <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>
  16. <h2><a name="description">Description</a></h2><p>The ibrowse application implements an HTTP 1.1 client. This
  17. module implements the API of the HTTP client. There is one named
  18. process called 'ibrowse' which assists in load balancing and maintaining configuration. There is one load balancing process per unique webserver. There is
  19. one process to handle one TCP connection to a webserver
  20. (implemented in the module ibrowse_http_client). Multiple connections to a
  21. webserver are setup based on the settings for each webserver. The
  22. ibrowse process also determines which connection to pipeline a
  23. certain request on. The functions to call are send_req/3,
  24. send_req/4, send_req/5, send_req/6.</p>
  25. <p>Here are a few sample invocations.</p>
  26. <code>
  27. ibrowse:send_req("http://intranet/messenger/", [], get).
  28. <br><br>
  29. ibrowse:send_req("http://www.google.com/", [], get, [],
  30. [{proxy_user, "XXXXX"},
  31. {proxy_password, "XXXXX"},
  32. {proxy_host, "proxy"},
  33. {proxy_port, 8080}], 1000).
  34. <br><br>
  35. ibrowse:send_req("http://www.erlang.org/download/otp_src_R10B-3.tar.gz", [], get, [],
  36. [{proxy_user, "XXXXX"},
  37. {proxy_password, "XXXXX"},
  38. {proxy_host, "proxy"},
  39. {proxy_port, 8080},
  40. {save_response_to_file, true}], 1000).
  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. <h2><a name="index">Function Index</a></h2>
  52. <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#all_trace_off-0">all_trace_off/0</a></td><td>Turn Off ALL tracing.</td></tr>
  53. <tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td></td></tr>
  54. <tr><td valign="top"><a href="#get_config_value-1">get_config_value/1</a></td><td>Internal export.</td></tr>
  55. <tr><td valign="top"><a href="#get_config_value-2">get_config_value/2</a></td><td>Internal export.</td></tr>
  56. <tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td></td></tr>
  57. <tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td></td></tr>
  58. <tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td></td></tr>
  59. <tr><td valign="top"><a href="#init-1">init/1</a></td><td></td></tr>
  60. <tr><td valign="top"><a href="#rescan_config-0">rescan_config/0</a></td><td>Clear current configuration for ibrowse and load from the file
  61. ibrowse.conf in the IBROWSE_EBIN/../priv directory.</td></tr>
  62. <tr><td valign="top"><a href="#rescan_config-1">rescan_config/1</a></td><td></td></tr>
  63. <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>
  64. <tr><td valign="top"><a href="#send_req-4">send_req/4</a></td><td>Same as send_req/3.</td></tr>
  65. <tr><td valign="top"><a href="#send_req-5">send_req/5</a></td><td>Same as send_req/4.</td></tr>
  66. <tr><td valign="top"><a href="#send_req-6">send_req/6</a></td><td>Same as send_req/5.</td></tr>
  67. <tr><td valign="top"><a href="#send_req_direct-4">send_req_direct/4</a></td><td>Same as send_req/3 except that the first argument is the PID
  68. returned by spawn_worker_process/2 or spawn_link_worker_process/2.</td></tr>
  69. <tr><td valign="top"><a href="#send_req_direct-5">send_req_direct/5</a></td><td>Same as send_req/4 except that the first argument is the PID
  70. returned by spawn_worker_process/2 or spawn_link_worker_process/2.</td></tr>
  71. <tr><td valign="top"><a href="#send_req_direct-6">send_req_direct/6</a></td><td>Same as send_req/5 except that the first argument is the PID
  72. returned by spawn_worker_process/2 or spawn_link_worker_process/2.</td></tr>
  73. <tr><td valign="top"><a href="#send_req_direct-7">send_req_direct/7</a></td><td>Same as send_req/6 except that the first argument is the PID
  74. returned by spawn_worker_process/2 or spawn_link_worker_process/2.</td></tr>
  75. <tr><td valign="top"><a href="#set_dest-3">set_dest/3</a></td><td>Deprecated.</td></tr>
  76. <tr><td valign="top"><a href="#set_max_pipeline_size-3">set_max_pipeline_size/3</a></td><td>Set the maximum pipeline size for each connection to a specific Host:Port.</td></tr>
  77. <tr><td valign="top"><a href="#set_max_sessions-3">set_max_sessions/3</a></td><td>Set the maximum number of connections allowed to a specific Host:Port.</td></tr>
  78. <tr><td valign="top"><a href="#show_dest_status-0">show_dest_status/0</a></td><td></td></tr>
  79. <tr><td valign="top"><a href="#show_dest_status-2">show_dest_status/2</a></td><td>Shows some internal information about load balancing to a
  80. specified Host:Port.</td></tr>
  81. <tr><td valign="top"><a href="#spawn_link_worker_process-1">spawn_link_worker_process/1</a></td><td>Same as spawn_worker_process/1 except the the calling process
  82. is linked to the worker process which is spawned.</td></tr>
  83. <tr><td valign="top"><a href="#spawn_link_worker_process-2">spawn_link_worker_process/2</a></td><td></td></tr>
  84. <tr><td valign="top"><a href="#spawn_worker_process-1">spawn_worker_process/1</a></td><td>Creates a HTTP client process to the specified Host:Port which
  85. is not part of the load balancing pool.</td></tr>
  86. <tr><td valign="top"><a href="#spawn_worker_process-2">spawn_worker_process/2</a></td><td></td></tr>
  87. <tr><td valign="top"><a href="#start-0">start/0</a></td><td>Starts the ibrowse process without linking.</td></tr>
  88. <tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td>Starts the ibrowse process linked to the calling process.</td></tr>
  89. <tr><td valign="top"><a href="#stop-0">stop/0</a></td><td>Stop the ibrowse process.</td></tr>
  90. <tr><td valign="top"><a href="#stop_worker_process-1">stop_worker_process/1</a></td><td>Terminate a worker process spawned using
  91. spawn_worker_process/2 or spawn_link_worker_process/2.</td></tr>
  92. <tr><td valign="top"><a href="#stream_next-1">stream_next/1</a></td><td>Tell ibrowse to stream the next chunk of data to the
  93. caller.</td></tr>
  94. <tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td></td></tr>
  95. <tr><td valign="top"><a href="#trace_off-0">trace_off/0</a></td><td>Turn tracing off for the ibrowse process.</td></tr>
  96. <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
  97. server.</td></tr>
  98. <tr><td valign="top"><a href="#trace_on-0">trace_on/0</a></td><td>Turn tracing on for the ibrowse process.</td></tr>
  99. <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
  100. server.</td></tr>
  101. </table>
  102. <h2><a name="functions">Function Details</a></h2>
  103. <h3 class="function"><a name="all_trace_off-0">all_trace_off/0</a></h3>
  104. <div class="spec">
  105. <p><tt>all_trace_off() -&gt; ok</tt></p>
  106. </div><p>Turn Off ALL tracing</p>
  107. <h3 class="function"><a name="code_change-3">code_change/3</a></h3>
  108. <div class="spec">
  109. <p><tt>code_change(OldVsn, State, Extra) -&gt; any()</tt></p>
  110. </div>
  111. <h3 class="function"><a name="get_config_value-1">get_config_value/1</a></h3>
  112. <div class="spec">
  113. <p><tt>get_config_value(Key) -&gt; any()</tt></p>
  114. </div><p>Internal export</p>
  115. <h3 class="function"><a name="get_config_value-2">get_config_value/2</a></h3>
  116. <div class="spec">
  117. <p><tt>get_config_value(Key, DefVal) -&gt; any()</tt></p>
  118. </div><p>Internal export</p>
  119. <h3 class="function"><a name="handle_call-3">handle_call/3</a></h3>
  120. <div class="spec">
  121. <p><tt>handle_call(Request, From, State) -&gt; any()</tt></p>
  122. </div>
  123. <h3 class="function"><a name="handle_cast-2">handle_cast/2</a></h3>
  124. <div class="spec">
  125. <p><tt>handle_cast(Msg, State) -&gt; any()</tt></p>
  126. </div>
  127. <h3 class="function"><a name="handle_info-2">handle_info/2</a></h3>
  128. <div class="spec">
  129. <p><tt>handle_info(Info, State) -&gt; any()</tt></p>
  130. </div>
  131. <h3 class="function"><a name="init-1">init/1</a></h3>
  132. <div class="spec">
  133. <p><tt>init(X1) -&gt; any()</tt></p>
  134. </div>
  135. <h3 class="function"><a name="rescan_config-0">rescan_config/0</a></h3>
  136. <div class="spec">
  137. <p><tt>rescan_config() -&gt; any()</tt></p>
  138. </div><p>Clear current configuration for ibrowse and load from the file
  139. ibrowse.conf in the IBROWSE_EBIN/../priv directory. Current
  140. configuration is cleared only if the ibrowse.conf file is readable
  141. using file:consult/1</p>
  142. <h3 class="function"><a name="rescan_config-1">rescan_config/1</a></h3>
  143. <div class="spec">
  144. <p><tt>rescan_config(File) -&gt; any()</tt></p>
  145. </div>
  146. <h3 class="function"><a name="send_req-3">send_req/3</a></h3>
  147. <div class="spec">
  148. <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>
  149. <ul class="definitions"><li><tt><a name="type-headerList">headerList()</a> = [{<a href="#type-header">header()</a>, <a href="#type-value">value()</a>}]</tt></li>
  150. <li><tt><a name="type-header">header()</a> = atom() | string()</tt></li>
  151. <li><tt><a name="type-value">value()</a> = term()</tt></li>
  152. <li><tt><a name="type-method">method()</a> = get | post | head | options | put | delete | trace | mkcol | propfind | proppatch | lock | unlock | move | copy</tt></li>
  153. <li><tt>Status = string()</tt></li>
  154. <li><tt>ResponseHeaders = [<a href="#type-respHeader">respHeader()</a>]</tt></li>
  155. <li><tt><a name="type-respHeader">respHeader()</a> = {<a href="#type-headerName">headerName()</a>, <a href="#type-headerValue">headerValue()</a>}</tt></li>
  156. <li><tt><a name="type-headerName">headerName()</a> = string()</tt></li>
  157. <li><tt><a name="type-headerValue">headerValue()</a> = string()</tt></li>
  158. <li><tt><a name="type-response">response()</a> = {ok, Status, ResponseHeaders, ResponseBody} | {ibrowse_req_id, <a href="#type-req_id">req_id()</a>} | {error, Reason}</tt></li>
  159. <li><tt><a name="type-req_id">req_id()</a> = term()</tt></li>
  160. <li><tt>ResponseBody = string() | {file, Filename}</tt></li>
  161. <li><tt>Reason = term()</tt></li>
  162. </ul></p>
  163. </div><p>This is the basic function to send a HTTP request.
  164. The Status return value indicates the HTTP status code returned by the webserver</p>
  165. <h3 class="function"><a name="send_req-4">send_req/4</a></h3>
  166. <div class="spec">
  167. <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>
  168. <ul class="definitions"><li><tt><a name="type-body">body()</a> = [] | string() | binary() | <a href="#type-fun_arity_0">fun_arity_0()</a> | {<a href="#type-fun_arity_1">fun_arity_1()</a>, <a href="#type-initial_state">initial_state()</a>}</tt></li>
  169. <li><tt><a name="type-initial_state">initial_state()</a> = term()</tt></li>
  170. </ul></p>
  171. </div><p>Same as send_req/3.
  172. If a list is specified for the body it has to be a flat list. The body can also be a fun/0 or a fun/1. <br>
  173. If fun/0, the connection handling process will repeatdely call the fun until it returns an error or eof. <pre>Fun() = {ok, Data} | eof</pre><br>
  174. If fun/1, the connection handling process will repeatedly call the fun with the supplied state until it returns an error or eof. <pre>Fun(State) = {ok, Data} | {ok, Data, NewState} | eof</pre></p>
  175. <h3 class="function"><a name="send_req-5">send_req/5</a></h3>
  176. <div class="spec">
  177. <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>
  178. <ul class="definitions"><li><tt><a name="type-optionList">optionList()</a> = [<a href="#type-option">option()</a>]</tt></li>
  179. <li><tt><a name="type-option">option()</a> = {max_sessions, integer()} | {response_format, <a href="#type-response_format">response_format()</a>} | {stream_chunk_size, 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-srtf">srtf()</a>} | {stream_to, <a href="#type-stream_to">stream_to()</a>} | {http_vsn, {MajorVsn, MinorVsn}} | {host_header, string()} | {inactivity_timeout, integer()} | {connect_timeout, integer()} | {socket_options, Sock_opts} | {transfer_encoding, {chunked, ChunkSize}} | {headers_as_is, <a href="#type-boolean">boolean()</a>} | {give_raw_headers, <a href="#type-boolean">boolean()</a>} | {preserve_chunked_encoding, <a href="#type-boolean">boolean()</a>}</tt></li>
  180. <li><tt><a name="type-stream_to">stream_to()</a> = <a href="#type-process">process()</a> | {<a href="#type-process">process()</a>, once}</tt></li>
  181. <li><tt><a name="type-process">process()</a> = pid() | atom()</tt></li>
  182. <li><tt><a name="type-username">username()</a> = string()</tt></li>
  183. <li><tt><a name="type-password">password()</a> = string()</tt></li>
  184. <li><tt>SSLOpt = term()</tt></li>
  185. <li><tt>Sock_opts = [Sock_opt]</tt></li>
  186. <li><tt>Sock_opt = term()</tt></li>
  187. <li><tt>ChunkSize = integer()</tt></li>
  188. <li><tt><a name="type-srtf">srtf()</a> = <a href="#type-boolean">boolean()</a> | <a href="#type-filename">filename()</a></tt></li>
  189. <li><tt><a name="type-filename">filename()</a> = string()</tt></li>
  190. <li><tt><a name="type-response_format">response_format()</a> = list | binary</tt></li>
  191. </ul></p>
  192. </div><p>Same as send_req/4.
  193. For a description of SSL Options, look in the <a href="http://www.erlang.org/doc/apps/ssl/index.html">ssl</a> manpage. If the
  194. HTTP Version to use is not specified, the default is 1.1.
  195. <br>
  196. <ul>
  197. <li>The <code>host_header</code> option is useful in the case where ibrowse is
  198. connecting to a component such as <a href="http://www.stunnel.org">stunnel</a> which then sets up a
  199. secure connection to a webserver. In this case, the URL supplied to
  200. ibrowse must have the stunnel host/port details, but that won't
  201. make sense to the destination webserver. This option can then be
  202. used to specify what should go in the <code>Host</code> header in
  203. the request.</li>
  204. <li>The <code>stream_to</code> option can be used to have the HTTP
  205. response streamed to a process as messages as data arrives on the
  206. socket. If the calling process wishes to control the rate at which
  207. data is received from the server, the option <code>{stream_to,
  208. {process(), once}}</code> can be specified. The calling process
  209. will have to invoke <code>ibrowse:stream_next(Request_id)</code> to
  210. receive the next packet.</li>
  211. <li>When both the options <code>save_response_to_file</code> and <code>stream_to</code>
  212. are specified, the former takes precedence.</li>
  213. <li>For the <code>save_response_to_file</code> option, the response body is saved to
  214. file only if the status code is in the 200-299 range. If not, the response body is returned
  215. as a string.</li>
  216. <li>Whenever an error occurs in the processing of a request, ibrowse will return as much
  217. information as it has, such as HTTP Status Code and HTTP Headers. When this happens, the response
  218. is of the form <code>{error, {Reason, {stat_code, StatusCode}, HTTP_headers}}</code></li>
  219. <li>The <code>inactivity_timeout</code> option is useful when
  220. dealing with large response bodies and/or slow links. In these
  221. cases, it might be hard to estimate how long a request will take to
  222. complete. In such cases, the client might want to timeout if no
  223. data has been received on the link for a certain time interval.</li>
  224. <li>
  225. The <code>connect_timeout</code> option is to specify how long the
  226. client process should wait for connection establishment. This is
  227. useful in scenarios where connections to servers are usually setup
  228. very fast, but responses might take much longer compared to
  229. connection setup. In such cases, it is better for the calling
  230. process to timeout faster if there is a problem (DNS lookup
  231. delays/failures, network routing issues, etc). The total timeout
  232. value specified for the request will enforced. To illustrate using
  233. an example:
  234. <code>
  235. ibrowse:send_req("http://www.example.com/cgi-bin/request", [], get, [], [{connect_timeout, 100}], 1000).
  236. </code>
  237. In the above invocation, if the connection isn't established within
  238. 100 milliseconds, the request will fail with
  239. <code>{error, conn_failed}</code>.<br>
  240. If connection setup succeeds, the total time allowed for the
  241. request to complete will be 1000 milliseconds minus the time taken
  242. for connection setup.
  243. </li>
  244. <li> The <code>socket_options</code> option can be used to set
  245. specific options on the socket. The <code>{active, true | false | once}</code>
  246. and <code>{packet_type, Packet_type}</code> will be filtered out by ibrowse. </li>
  247. <li> The <code>headers_as_is</code> option is to enable the caller
  248. to send headers exactly as specified in the request without ibrowse
  249. adding some of its own. Required for some picky servers apparently. </li>
  250. <li>The <code>give_raw_headers</code> option is to enable the
  251. caller to get access to the raw status line and raw unparsed
  252. headers. Not quite sure why someone would want this, but one of my
  253. users asked for it, so here it is. </li>
  254. <li> The <code>preserve_chunked_encoding</code> option enables the caller
  255. to receive the raw data stream when the Transfer-Encoding of the server
  256. response is Chunked.
  257. </li>
  258. </ul>
  259. </p>
  260. <h3 class="function"><a name="send_req-6">send_req/6</a></h3>
  261. <div class="spec">
  262. <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>
  263. <ul class="definitions"><li><tt>Timeout = integer() | infinity</tt></li>
  264. </ul></p>
  265. </div><p>Same as send_req/5.
  266. All timeout values are in milliseconds.</p>
  267. <h3 class="function"><a name="send_req_direct-4">send_req_direct/4</a></h3>
  268. <div class="spec">
  269. <p><tt>send_req_direct(Conn_pid, Url, Headers, Method) -&gt; any()</tt></p>
  270. </div><p>Same as send_req/3 except that the first argument is the PID
  271. returned by spawn_worker_process/2 or spawn_link_worker_process/2</p>
  272. <h3 class="function"><a name="send_req_direct-5">send_req_direct/5</a></h3>
  273. <div class="spec">
  274. <p><tt>send_req_direct(Conn_pid, Url, Headers, Method, Body) -&gt; any()</tt></p>
  275. </div><p>Same as send_req/4 except that the first argument is the PID
  276. returned by spawn_worker_process/2 or spawn_link_worker_process/2</p>
  277. <h3 class="function"><a name="send_req_direct-6">send_req_direct/6</a></h3>
  278. <div class="spec">
  279. <p><tt>send_req_direct(Conn_pid, Url, Headers, Method, Body, Options) -&gt; any()</tt></p>
  280. </div><p>Same as send_req/5 except that the first argument is the PID
  281. returned by spawn_worker_process/2 or spawn_link_worker_process/2</p>
  282. <h3 class="function"><a name="send_req_direct-7">send_req_direct/7</a></h3>
  283. <div class="spec">
  284. <p><tt>send_req_direct(Conn_pid, Url, Headers, Method, Body, Options, Timeout) -&gt; any()</tt></p>
  285. </div><p>Same as send_req/6 except that the first argument is the PID
  286. returned by spawn_worker_process/2 or spawn_link_worker_process/2</p>
  287. <h3 class="function"><a name="set_dest-3">set_dest/3</a></h3>
  288. <div class="spec">
  289. <p><tt>set_dest(Host, Port, T) -&gt; any()</tt></p>
  290. </div><p>Deprecated. Use set_max_sessions/3 and set_max_pipeline_size/3
  291. for achieving the same effect.</p>
  292. <h3 class="function"><a name="set_max_pipeline_size-3">set_max_pipeline_size/3</a></h3>
  293. <div class="spec">
  294. <p><tt>set_max_pipeline_size(Host::string(), Port::integer(), Max::integer()) -&gt; ok</tt></p>
  295. </div><p>Set the maximum pipeline size for each connection to a specific Host:Port.</p>
  296. <h3 class="function"><a name="set_max_sessions-3">set_max_sessions/3</a></h3>
  297. <div class="spec">
  298. <p><tt>set_max_sessions(Host::string(), Port::integer(), Max::integer()) -&gt; ok</tt></p>
  299. </div><p>Set the maximum number of connections allowed to a specific Host:Port.</p>
  300. <h3 class="function"><a name="show_dest_status-0">show_dest_status/0</a></h3>
  301. <div class="spec">
  302. <p><tt>show_dest_status() -&gt; any()</tt></p>
  303. </div>
  304. <h3 class="function"><a name="show_dest_status-2">show_dest_status/2</a></h3>
  305. <div class="spec">
  306. <p><tt>show_dest_status(Host, Port) -&gt; any()</tt></p>
  307. </div><p>Shows some internal information about load balancing to a
  308. specified Host:Port. Info about workers spawned using
  309. spawn_worker_process/2 or spawn_link_worker_process/2 is not
  310. included.</p>
  311. <h3 class="function"><a name="spawn_link_worker_process-1">spawn_link_worker_process/1</a></h3>
  312. <div class="spec">
  313. <p><tt>spawn_link_worker_process(Url::string()) -&gt; {ok, pid()}</tt></p>
  314. </div><p>Same as spawn_worker_process/1 except the the calling process
  315. is linked to the worker process which is spawned.</p>
  316. <h3 class="function"><a name="spawn_link_worker_process-2">spawn_link_worker_process/2</a></h3>
  317. <div class="spec">
  318. <p><tt>spawn_link_worker_process(Host::string(), Port::integer()) -&gt; {ok, pid()}</tt></p>
  319. </div>
  320. <h3 class="function"><a name="spawn_worker_process-1">spawn_worker_process/1</a></h3>
  321. <div class="spec">
  322. <p><tt>spawn_worker_process(Url::string()) -&gt; {ok, pid()}</tt></p>
  323. </div><p>Creates a HTTP client process to the specified Host:Port which
  324. is not part of the load balancing pool. This is useful in cases
  325. where some requests to a webserver might take a long time whereas
  326. some might take a very short time. To avoid getting these quick
  327. requests stuck in the pipeline behind time consuming requests, use
  328. this function to get a handle to a connection process. <br>
  329. <b>Note:</b> Calling this function only creates a worker process. No connection
  330. is setup. The connection attempt is made only when the first
  331. request is sent via any of the send_req_direct/4,5,6,7 functions.<br>
  332. <b>Note:</b> It is the responsibility of the calling process to control
  333. pipeline size on such connections.
  334. </p>
  335. <h3 class="function"><a name="spawn_worker_process-2">spawn_worker_process/2</a></h3>
  336. <div class="spec">
  337. <p><tt>spawn_worker_process(Host::string(), Port::integer()) -&gt; {ok, pid()}</tt></p>
  338. </div>
  339. <h3 class="function"><a name="start-0">start/0</a></h3>
  340. <div class="spec">
  341. <p><tt>start() -&gt; any()</tt></p>
  342. </div><p>Starts the ibrowse process without linking. Useful when testing using the shell</p>
  343. <h3 class="function"><a name="start_link-0">start_link/0</a></h3>
  344. <div class="spec">
  345. <p><tt>start_link() -&gt; {ok, pid()}</tt></p>
  346. </div><p>Starts the ibrowse process linked to the calling process. Usually invoked by the supervisor ibrowse_sup</p>
  347. <h3 class="function"><a name="stop-0">stop/0</a></h3>
  348. <div class="spec">
  349. <p><tt>stop() -&gt; any()</tt></p>
  350. </div><p>Stop the ibrowse process. Useful when testing using the shell.</p>
  351. <h3 class="function"><a name="stop_worker_process-1">stop_worker_process/1</a></h3>
  352. <div class="spec">
  353. <p><tt>stop_worker_process(Conn_pid::pid()) -&gt; ok</tt></p>
  354. </div><p>Terminate a worker process spawned using
  355. spawn_worker_process/2 or spawn_link_worker_process/2. Requests in
  356. progress will get the error response <pre>{error, closing_on_request}</pre></p>
  357. <h3 class="function"><a name="stream_next-1">stream_next/1</a></h3>
  358. <div class="spec">
  359. <p><tt>stream_next(Req_id::<a href="#type-req_id">req_id()</a>) -&gt; ok | {error, unknown_req_id}</tt></p>
  360. </div><p>Tell ibrowse to stream the next chunk of data to the
  361. caller. Should be used in conjunction with the
  362. <code>stream_to</code> option</p>
  363. <h3 class="function"><a name="terminate-2">terminate/2</a></h3>
  364. <div class="spec">
  365. <p><tt>terminate(Reason, State) -&gt; any()</tt></p>
  366. </div>
  367. <h3 class="function"><a name="trace_off-0">trace_off/0</a></h3>
  368. <div class="spec">
  369. <p><tt>trace_off() -&gt; any()</tt></p>
  370. </div><p>Turn tracing off for the ibrowse process</p>
  371. <h3 class="function"><a name="trace_off-2">trace_off/2</a></h3>
  372. <div class="spec">
  373. <p><tt>trace_off(Host, Port) -&gt; ok</tt></p>
  374. </div><p>Turn tracing OFF for all connections to the specified HTTP
  375. server.</p>
  376. <h3 class="function"><a name="trace_on-0">trace_on/0</a></h3>
  377. <div class="spec">
  378. <p><tt>trace_on() -&gt; any()</tt></p>
  379. </div><p>Turn tracing on for the ibrowse process</p>
  380. <h3 class="function"><a name="trace_on-2">trace_on/2</a></h3>
  381. <div class="spec">
  382. <p><tt>trace_on(Host, Port) -&gt; ok</tt>
  383. <ul class="definitions"><li><tt>Host = string()</tt></li>
  384. <li><tt>Port = integer()</tt></li>
  385. </ul></p>
  386. </div><p>Turn tracing on for all connections to the specified HTTP
  387. server. Host is whatever is specified as the domain name in the URL</p>
  388. <hr>
  389. <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  390. <p><i>Generated by EDoc, Sep 22 2010, 22:56:44.</i></p>
  391. </body>
  392. </html>