~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/inets/doc/src/http_client.xml

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="latin1" ?>
 
1
<?xml version="1.0" encoding="iso-8859-1" ?>
2
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
3
3
 
4
4
<chapter>
5
5
  <header>
6
6
    <copyright>
7
 
      <year>2004</year><year>2009</year>
 
7
      <year>2004</year><year>2010</year>
8
8
      <holder>Ericsson AB. All Rights Reserved.</holder>
9
9
    </copyright>
10
10
    <legalnotice>
42
42
    dynamically in runtime. Each client profile will spawn a new
43
43
    process to handle each request unless there is a possibility to use
44
44
    a persistent connection with or without pipelining.
45
 
    The client will add a host header and an empty
46
 
    te header if there are no such headers present in the request.</p>
 
45
    The client will add a <c>host</c> header and an empty
 
46
    <c>te</c> header if there are no such headers present in the request.</p>
47
47
 
48
 
    <p>The clients supports ipv6 as long as the underlying mechanisms also do
 
48
    <p>The client supports ipv6 as long as the underlying mechanisms also do
49
49
      so.</p>
50
50
  </section>
51
51
 
56
56
    <pre>
57
57
      [{inets, [{services, [{httpc, PropertyList}]}]}]
58
58
    </pre>
59
 
    <p>For valid properties see <seealso
60
 
                               marker="http">http(3)</seealso></p>
 
59
    <p>For valid properties see 
 
60
    <seealso marker="httpc">httpc(3)</seealso>. </p>
61
61
  </section>
62
62
 
63
63
  <section>
71
71
      but not for requests to localhost. This will apply to all subsequent
72
72
      requests</p>
73
73
    <code type="erl">
74
 
      2 > http:set_options([{proxy, {{"www-proxy.mycompany.com", 8000},
 
74
      2 > httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000},
75
75
      ["localhost"]}}]).
76
76
      ok
77
77
    </code>
78
78
    <p>An ordinary synchronous request. </p>
79
79
    <code type="erl">
80
80
      3 > {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} =
81
 
      http:request(get, {"http://www.erlang.org", []}, [], []).
 
81
      httpc:request(get, {"http://www.erlang.org", []}, [], []).
82
82
    </code>
83
83
    <p>With all default values, as above, a get request can also be written
84
84
      like this.</p>
85
85
    <code type="erl">
86
86
      4 > {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} =
87
 
      http:request("http://www.erlang.org").
 
87
      httpc:request("http://www.erlang.org").
88
88
    </code>
89
89
    <p>An ordinary asynchronous request. The result will be sent
90
 
      to the calling process on the form {http, {ReqestId, Result}}</p>
 
90
      to the calling process in the form <c>{http, {ReqestId, Result}}</c></p>
91
91
    <code type="erl">
92
92
      5 > {ok, RequestId} =
93
 
      http:request(get, {"http://www.erlang.org", []}, [], [{sync, false}]).
 
93
      httpc:request(get, {"http://www.erlang.org", []}, [], [{sync, false}]).
94
94
    </code>
95
95
    <p>In this case the calling process is the shell, so we receive the
96
96
      result.</p>
97
97
    <code type="erl">
98
 
      6 >  receive {http, {RequestId, Result}} -> ok after 500 -> error end.
 
98
      6 > receive {http, {RequestId, Result}} -> ok after 500 -> error end.
99
99
      ok
100
100
    </code>
101
101
    <p>Send a request with a specified connection header. </p>
102
102
    <code type="erl">
103
103
      7 > {ok, {{NewVersion, 200, NewReasonPhrase}, NewHeaders, NewBody}} =
104
 
      http:request(get, {"http://www.erlang.org", [{"connection", "close"}]},
 
104
      httpc:request(get, {"http://www.erlang.org", [{"connection", "close"}]},
105
105
      [], []).
106
106
    </code>
107
107
 
108
108
    <p>Start a HTTP client profile. </p>
109
109
   
110
110
    <code><![CDATA[
111
 
      8 >  {ok, Pid} = inets:start(httpc, [{profile, foo}]).
 
111
      8 > {ok, Pid} = inets:start(httpc, [{profile, foo}]).
112
112
      {ok, <0.45.0>}       
113
113
      ]]></code>
114
114
    
115
115
    <p>The new profile has no proxy settings so the connection will
116
116
      be refused</p>
117
117
      <code type="erl">
118
 
      9 > http:request("http://www.erlang.org", foo).              
119
 
      {error,econnrefused}
 
118
      9 > httpc:request("http://www.erlang.org", foo). 
 
119
      {error, econnrefused}
120
120
    </code>
121
121
 
122
122
    <p>Stop a HTTP client profile. </p>
123
123
    <code type="erl">
124
 
      10 >  inets:stop(httpc, foo).
 
124
      10 > inets:stop(httpc, foo).
125
125
      ok
126
126
    </code>
127
127
    
128
128
    <p>Alternatively:</p>
129
129
    <code type="erl">
130
 
      10 >  inets:stop(httpc, Pid).
 
130
      10 > inets:stop(httpc, Pid).
131
131
      ok
132
132
    </code>
133
133
    
134
 
    
135
134
  </section>
136
135
</chapter>
137
136