You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

472 regels
27 KiB

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