mechanize 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mechanize might be problematic. Click here for more details.

Files changed (243) hide show
  1. data/EXAMPLES +55 -0
  2. data/README +3 -12
  3. data/lib/mechanize/cookie.rb +1 -2
  4. data/lib/mechanize/form.rb +182 -0
  5. data/lib/mechanize/form_elements.rb +105 -0
  6. data/lib/mechanize/page.rb +130 -0
  7. data/lib/mechanize/page_elements.rb +28 -0
  8. data/lib/mechanize.rb +27 -369
  9. data/test/htdocs/file_upload.html +13 -0
  10. data/test/htdocs/frame_test.html +23 -0
  11. data/test/server.rb +1 -0
  12. data/test/servlets.rb +6 -0
  13. data/test/tc_cookies.rb +2 -3
  14. data/test/tc_forms.rb +2 -3
  15. data/test/tc_frames.rb +22 -0
  16. data/test/tc_links.rb +2 -3
  17. data/test/tc_mech.rb +2 -3
  18. data/test/tc_response_code.rb +2 -3
  19. data/test/tc_upload.rb +34 -0
  20. data/test/test_includes.rb +5 -0
  21. data/test/ts_mech.rb +2 -0
  22. metadata +59 -307
  23. data/doc/classes/Net/HTTP/Copy.html +0 -134
  24. data/doc/classes/Net/HTTP/Delete.html +0 -134
  25. data/doc/classes/Net/HTTP/Get.html +0 -134
  26. data/doc/classes/Net/HTTP/Head.html +0 -134
  27. data/doc/classes/Net/HTTP/Lock.html +0 -134
  28. data/doc/classes/Net/HTTP/Mkcol.html +0 -134
  29. data/doc/classes/Net/HTTP/Move.html +0 -134
  30. data/doc/classes/Net/HTTP/Options.html +0 -134
  31. data/doc/classes/Net/HTTP/Post.html +0 -134
  32. data/doc/classes/Net/HTTP/Propfind.html +0 -134
  33. data/doc/classes/Net/HTTP/Proppatch.html +0 -134
  34. data/doc/classes/Net/HTTP/Put.html +0 -134
  35. data/doc/classes/Net/HTTP/Trace.html +0 -134
  36. data/doc/classes/Net/HTTP/Unlock.html +0 -134
  37. data/doc/classes/Net/HTTP.html +0 -1716
  38. data/doc/classes/Net/HTTP.src/M000103.html +0 -18
  39. data/doc/classes/Net/HTTP.src/M000104.html +0 -18
  40. data/doc/classes/Net/HTTP.src/M000105.html +0 -18
  41. data/doc/classes/Net/HTTP.src/M000106.html +0 -18
  42. data/doc/classes/Net/HTTP.src/M000107.html +0 -29
  43. data/doc/classes/Net/HTTP.src/M000108.html +0 -18
  44. data/doc/classes/Net/HTTP.src/M000109.html +0 -22
  45. data/doc/classes/Net/HTTP.src/M000110.html +0 -18
  46. data/doc/classes/Net/HTTP.src/M000111.html +0 -18
  47. data/doc/classes/Net/HTTP.src/M000112.html +0 -18
  48. data/doc/classes/Net/HTTP.src/M000113.html +0 -18
  49. data/doc/classes/Net/HTTP.src/M000114.html +0 -22
  50. data/doc/classes/Net/HTTP.src/M000115.html +0 -29
  51. data/doc/classes/Net/HTTP.src/M000116.html +0 -18
  52. data/doc/classes/Net/HTTP.src/M000117.html +0 -19
  53. data/doc/classes/Net/HTTP.src/M000118.html +0 -19
  54. data/doc/classes/Net/HTTP.src/M000119.html +0 -18
  55. data/doc/classes/Net/HTTP.src/M000121.html +0 -18
  56. data/doc/classes/Net/HTTP.src/M000122.html +0 -28
  57. data/doc/classes/Net/HTTP.src/M000123.html +0 -19
  58. data/doc/classes/Net/HTTP.src/M000124.html +0 -30
  59. data/doc/classes/Net/HTTP.src/M000125.html +0 -18
  60. data/doc/classes/Net/HTTP.src/M000126.html +0 -18
  61. data/doc/classes/Net/HTTP.src/M000127.html +0 -18
  62. data/doc/classes/Net/HTTP.src/M000128.html +0 -18
  63. data/doc/classes/Net/HTTP.src/M000129.html +0 -18
  64. data/doc/classes/Net/HTTP.src/M000130.html +0 -18
  65. data/doc/classes/Net/HTTP.src/M000133.html +0 -28
  66. data/doc/classes/Net/HTTP.src/M000134.html +0 -20
  67. data/doc/classes/Net/HTTP.src/M000135.html +0 -28
  68. data/doc/classes/Net/HTTP.src/M000136.html +0 -18
  69. data/doc/classes/Net/HTTP.src/M000137.html +0 -18
  70. data/doc/classes/Net/HTTP.src/M000138.html +0 -18
  71. data/doc/classes/Net/HTTP.src/M000139.html +0 -18
  72. data/doc/classes/Net/HTTP.src/M000140.html +0 -18
  73. data/doc/classes/Net/HTTP.src/M000141.html +0 -18
  74. data/doc/classes/Net/HTTP.src/M000142.html +0 -18
  75. data/doc/classes/Net/HTTP.src/M000143.html +0 -18
  76. data/doc/classes/Net/HTTP.src/M000144.html +0 -18
  77. data/doc/classes/Net/HTTP.src/M000145.html +0 -18
  78. data/doc/classes/Net/HTTP.src/M000146.html +0 -18
  79. data/doc/classes/Net/HTTP.src/M000147.html +0 -18
  80. data/doc/classes/Net/HTTP.src/M000148.html +0 -18
  81. data/doc/classes/Net/HTTP.src/M000152.html +0 -19
  82. data/doc/classes/Net/HTTP.src/M000153.html +0 -39
  83. data/doc/classes/Net/HTTP.src/M000154.html +0 -18
  84. data/doc/classes/Net/HTTP.src/M000156.html +0 -24
  85. data/doc/classes/Net/HTTP.src/M000157.html +0 -18
  86. data/doc/classes/Net/HTTP.src/M000158.html +0 -19
  87. data/doc/classes/Net/HTTP.src/M000159.html +0 -21
  88. data/doc/classes/Net/HTTP.src/M000161.html +0 -19
  89. data/doc/classes/Net/HTTPError.html +0 -120
  90. data/doc/classes/Net/HTTPExceptions.html +0 -137
  91. data/doc/classes/Net/HTTPFatalError.html +0 -120
  92. data/doc/classes/Net/HTTPGenericRequest.html +0 -274
  93. data/doc/classes/Net/HTTPGenericRequest.src/M000088.html +0 -26
  94. data/doc/classes/Net/HTTPGenericRequest.src/M000089.html +0 -18
  95. data/doc/classes/Net/HTTPGenericRequest.src/M000090.html +0 -18
  96. data/doc/classes/Net/HTTPGenericRequest.src/M000091.html +0 -18
  97. data/doc/classes/Net/HTTPGenericRequest.src/M000092.html +0 -19
  98. data/doc/classes/Net/HTTPGenericRequest.src/M000093.html +0 -20
  99. data/doc/classes/Net/HTTPGenericRequest.src/M000094.html +0 -20
  100. data/doc/classes/Net/HTTPHeader.html +0 -734
  101. data/doc/classes/Net/HTTPHeader.src/M000055.html +0 -23
  102. data/doc/classes/Net/HTTPHeader.src/M000056.html +0 -19
  103. data/doc/classes/Net/HTTPHeader.src/M000057.html +0 -22
  104. data/doc/classes/Net/HTTPHeader.src/M000058.html +0 -22
  105. data/doc/classes/Net/HTTPHeader.src/M000059.html +0 -19
  106. data/doc/classes/Net/HTTPHeader.src/M000060.html +0 -19
  107. data/doc/classes/Net/HTTPHeader.src/M000061.html +0 -20
  108. data/doc/classes/Net/HTTPHeader.src/M000063.html +0 -18
  109. data/doc/classes/Net/HTTPHeader.src/M000065.html +0 -20
  110. data/doc/classes/Net/HTTPHeader.src/M000066.html +0 -20
  111. data/doc/classes/Net/HTTPHeader.src/M000067.html +0 -18
  112. data/doc/classes/Net/HTTPHeader.src/M000068.html +0 -18
  113. data/doc/classes/Net/HTTPHeader.src/M000069.html +0 -18
  114. data/doc/classes/Net/HTTPHeader.src/M000070.html +0 -20
  115. data/doc/classes/Net/HTTPHeader.src/M000072.html +0 -30
  116. data/doc/classes/Net/HTTPHeader.src/M000073.html +0 -43
  117. data/doc/classes/Net/HTTPHeader.src/M000075.html +0 -21
  118. data/doc/classes/Net/HTTPHeader.src/M000076.html +0 -22
  119. data/doc/classes/Net/HTTPHeader.src/M000077.html +0 -20
  120. data/doc/classes/Net/HTTPHeader.src/M000078.html +0 -21
  121. data/doc/classes/Net/HTTPHeader.src/M000079.html +0 -19
  122. data/doc/classes/Net/HTTPHeader.src/M000080.html +0 -18
  123. data/doc/classes/Net/HTTPHeader.src/M000081.html +0 -19
  124. data/doc/classes/Net/HTTPHeader.src/M000082.html +0 -19
  125. data/doc/classes/Net/HTTPHeader.src/M000083.html +0 -23
  126. data/doc/classes/Net/HTTPHeader.src/M000084.html +0 -18
  127. data/doc/classes/Net/HTTPHeader.src/M000086.html +0 -18
  128. data/doc/classes/Net/HTTPHeader.src/M000087.html +0 -18
  129. data/doc/classes/Net/HTTPRequest.html +0 -150
  130. data/doc/classes/Net/HTTPRequest.src/M000102.html +0 -21
  131. data/doc/classes/Net/HTTPResponse.html +0 -425
  132. data/doc/classes/Net/HTTPResponse.src/M000162.html +0 -18
  133. data/doc/classes/Net/HTTPResponse.src/M000163.html +0 -18
  134. data/doc/classes/Net/HTTPResponse.src/M000164.html +0 -23
  135. data/doc/classes/Net/HTTPResponse.src/M000165.html +0 -18
  136. data/doc/classes/Net/HTTPResponse.src/M000166.html +0 -32
  137. data/doc/classes/Net/HTTPResponse.src/M000167.html +0 -18
  138. data/doc/classes/Net/HTTPRetriableError.html +0 -120
  139. data/doc/classes/Net/HTTPServerException.html +0 -120
  140. data/doc/classes/Net/ProtoAuthError.html +0 -113
  141. data/doc/classes/Net/ProtoCommandError.html +0 -113
  142. data/doc/classes/Net/ProtoFatalError.html +0 -113
  143. data/doc/classes/Net/ProtoRetriableError.html +0 -113
  144. data/doc/classes/Net/ProtoServerError.html +0 -113
  145. data/doc/classes/Net/ProtoSyntaxError.html +0 -113
  146. data/doc/classes/Net/ProtoUnknownError.html +0 -113
  147. data/doc/classes/Net/ProtocolError.html +0 -111
  148. data/doc/classes/Net/WriteAdapter.html +0 -235
  149. data/doc/classes/Net/WriteAdapter.src/M000095.html +0 -19
  150. data/doc/classes/Net/WriteAdapter.src/M000096.html +0 -18
  151. data/doc/classes/Net/WriteAdapter.src/M000097.html +0 -18
  152. data/doc/classes/Net/WriteAdapter.src/M000099.html +0 -19
  153. data/doc/classes/Net/WriteAdapter.src/M000100.html +0 -18
  154. data/doc/classes/Net/WriteAdapter.src/M000101.html +0 -18
  155. data/doc/classes/REXML/Comment.html +0 -137
  156. data/doc/classes/REXML/Comment.src/M000053.html +0 -18
  157. data/doc/classes/REXML/Node.html +0 -240
  158. data/doc/classes/REXML/Node.src/M000047.html +0 -21
  159. data/doc/classes/REXML/Node.src/M000048.html +0 -21
  160. data/doc/classes/REXML/Node.src/M000049.html +0 -22
  161. data/doc/classes/REXML/Node.src/M000050.html +0 -18
  162. data/doc/classes/REXML/Node.src/M000051.html +0 -18
  163. data/doc/classes/REXML/Node.src/M000052.html +0 -18
  164. data/doc/classes/REXML/Text.html +0 -137
  165. data/doc/classes/REXML/Text.src/M000054.html +0 -18
  166. data/doc/classes/REXML.html +0 -109
  167. data/doc/classes/WWW/Button.html +0 -190
  168. data/doc/classes/WWW/Button.src/M000028.html +0 -18
  169. data/doc/classes/WWW/Button.src/M000029.html +0 -18
  170. data/doc/classes/WWW/Button.src/M000030.html +0 -25
  171. data/doc/classes/WWW/CheckBox.html +0 -160
  172. data/doc/classes/WWW/CheckBox.src/M000024.html +0 -18
  173. data/doc/classes/WWW/Cookie.html +0 -207
  174. data/doc/classes/WWW/Cookie.src/M000032.html +0 -59
  175. data/doc/classes/WWW/Cookie.src/M000033.html +0 -21
  176. data/doc/classes/WWW/Cookie.src/M000034.html +0 -18
  177. data/doc/classes/WWW/CookieJar.html +0 -197
  178. data/doc/classes/WWW/CookieJar.src/M000008.html +0 -18
  179. data/doc/classes/WWW/CookieJar.src/M000009.html +0 -22
  180. data/doc/classes/WWW/CookieJar.src/M000010.html +0 -33
  181. data/doc/classes/WWW/CookieJar.src/M000011.html +0 -18
  182. data/doc/classes/WWW/Field.html +0 -174
  183. data/doc/classes/WWW/Field.src/M000045.html +0 -18
  184. data/doc/classes/WWW/Field.src/M000046.html +0 -26
  185. data/doc/classes/WWW/FileUpload.html +0 -163
  186. data/doc/classes/WWW/FileUpload.src/M000031.html +0 -19
  187. data/doc/classes/WWW/Form.html +0 -152
  188. data/doc/classes/WWW/Form.src/M000044.html +0 -19
  189. data/doc/classes/WWW/GlobalForm.html +0 -271
  190. data/doc/classes/WWW/GlobalForm.src/M000004.html +0 -24
  191. data/doc/classes/WWW/GlobalForm.src/M000005.html +0 -26
  192. data/doc/classes/WWW/GlobalForm.src/M000006.html +0 -46
  193. data/doc/classes/WWW/GlobalForm.src/M000007.html +0 -46
  194. data/doc/classes/WWW/ImageButton.html +0 -157
  195. data/doc/classes/WWW/ImageButton.src/M000027.html +0 -22
  196. data/doc/classes/WWW/Link.html +0 -160
  197. data/doc/classes/WWW/Link.src/M000025.html +0 -20
  198. data/doc/classes/WWW/Mechanize.html +0 -379
  199. data/doc/classes/WWW/Mechanize.src/M000013.html +0 -21
  200. data/doc/classes/WWW/Mechanize.src/M000014.html +0 -18
  201. data/doc/classes/WWW/Mechanize.src/M000015.html +0 -24
  202. data/doc/classes/WWW/Mechanize.src/M000016.html +0 -19
  203. data/doc/classes/WWW/Mechanize.src/M000017.html +0 -23
  204. data/doc/classes/WWW/Mechanize.src/M000018.html +0 -32
  205. data/doc/classes/WWW/Mechanize.src/M000019.html +0 -19
  206. data/doc/classes/WWW/Mechanize.src/M000020.html +0 -18
  207. data/doc/classes/WWW/Mechanize.src/M000021.html +0 -33
  208. data/doc/classes/WWW/Mechanize.src/M000022.html +0 -18
  209. data/doc/classes/WWW/Meta.html +0 -113
  210. data/doc/classes/WWW/Page.html +0 -313
  211. data/doc/classes/WWW/Page.src/M000036.html +0 -18
  212. data/doc/classes/WWW/Page.src/M000037.html +0 -18
  213. data/doc/classes/WWW/Page.src/M000038.html +0 -18
  214. data/doc/classes/WWW/Page.src/M000039.html +0 -19
  215. data/doc/classes/WWW/Page.src/M000040.html +0 -19
  216. data/doc/classes/WWW/Page.src/M000041.html +0 -19
  217. data/doc/classes/WWW/Page.src/M000042.html +0 -19
  218. data/doc/classes/WWW/Page.src/M000043.html +0 -19
  219. data/doc/classes/WWW/RadioButton.html +0 -160
  220. data/doc/classes/WWW/RadioButton.src/M000012.html +0 -18
  221. data/doc/classes/WWW/ResponseCodeError.html +0 -150
  222. data/doc/classes/WWW/ResponseCodeError.src/M000035.html +0 -18
  223. data/doc/classes/WWW/SelectList.html +0 -160
  224. data/doc/classes/WWW/SelectList.src/M000026.html +0 -28
  225. data/doc/classes/WWW.html +0 -130
  226. data/doc/created.rid +0 -1
  227. data/doc/files/CHANGELOG.html +0 -136
  228. data/doc/files/LICENSE.html +0 -531
  229. data/doc/files/README.html +0 -161
  230. data/doc/files/lib/mechanize/cookie_rb.html +0 -101
  231. data/doc/files/lib/mechanize/net-overrides/net/http_rb.html +0 -139
  232. data/doc/files/lib/mechanize/net-overrides/net/https_rb.html +0 -109
  233. data/doc/files/lib/mechanize/net-overrides/net/protocol_rb.html +0 -117
  234. data/doc/files/lib/mechanize/parsing_rb.html +0 -267
  235. data/doc/files/lib/mechanize/parsing_rb.src/M000001.html +0 -22
  236. data/doc/files/lib/mechanize/parsing_rb.src/M000002.html +0 -44
  237. data/doc/files/lib/mechanize/parsing_rb.src/M000003.html +0 -34
  238. data/doc/files/lib/mechanize_rb.html +0 -152
  239. data/doc/fr_class_index.html +0 -80
  240. data/doc/fr_file_index.html +0 -35
  241. data/doc/fr_method_index.html +0 -194
  242. data/doc/index.html +0 -24
  243. data/doc/rdoc-style.css +0 -208
@@ -1,1716 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Net::HTTP</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Net::HTTP</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/mechanize/net-overrides/net/http_rb.html">
59
- lib/mechanize/net-overrides/net/http.rb
60
- </a>
61
- <br />
62
- <a href="../../files/lib/mechanize/net-overrides/net/https_rb.html">
63
- lib/mechanize/net-overrides/net/https.rb
64
- </a>
65
- <br />
66
- </td>
67
- </tr>
68
-
69
- <tr class="top-aligned-row">
70
- <td><strong>Parent:</strong></td>
71
- <td>
72
- Protocol
73
- </td>
74
- </tr>
75
- </table>
76
- </div>
77
- <!-- banner header -->
78
-
79
- <div id="bodyContent">
80
-
81
-
82
-
83
- <div id="contextContent">
84
-
85
- <div id="description">
86
- <h2>What Is This Library?</h2>
87
- <p>
88
- This library provides your program functions to access <a
89
- href="../WWW.html">WWW</a> documents via <a href="HTTP.html">HTTP</a>,
90
- Hyper Text Transfer Protocol version 1.1. For details of <a
91
- href="HTTP.html">HTTP</a>, refer [RFC2616] (<a
92
- href="http://www.ietf.org/rfc/rfc2616.txt">www.ietf.org/rfc/rfc2616.txt</a>).
93
- </p>
94
- <h2>Examples</h2>
95
- <h3>Getting Document From <a href="../WWW.html">WWW</a> Server</h3>
96
- <p>
97
- (formal version)
98
- </p>
99
- <pre>
100
- require 'net/http'
101
- Net::HTTP.start('www.example.com', 80) {|http|
102
- response = http.get('/index.html')
103
- puts response.body
104
- }
105
- </pre>
106
- <p>
107
- (shorter version)
108
- </p>
109
- <pre>
110
- require 'net/http'
111
- Net::HTTP.get_print 'www.example.com', '/index.html'
112
-
113
- or
114
-
115
- require 'net/http'
116
- require 'uri'
117
- Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
118
- </pre>
119
- <h3>Posting Form Data</h3>
120
- <pre>
121
- require 'net/http'
122
- Net::HTTP.start('some.www.server', 80) {|http|
123
- response = http.post('/cgi-bin/search.rb', 'query=ruby')
124
- }
125
- </pre>
126
- <h3>Accessing via <a href="HTTP.html#M000124">Proxy</a></h3>
127
- <p>
128
- <a href="HTTP.html#M000124">Net::HTTP.Proxy</a> creates http proxy class.
129
- It has same methods of <a href="HTTP.html">Net::HTTP</a> but its instances
130
- always connect to proxy, instead of given host.
131
- </p>
132
- <pre>
133
- require 'net/http'
134
-
135
- proxy_addr = 'your.proxy.host'
136
- proxy_port = 8080
137
- :
138
- Net::HTTP::Proxy(proxy_addr, proxy_port).start('www.example.com') {|http|
139
- # always connect to your.proxy.addr:8080
140
- :
141
- }
142
- </pre>
143
- <p>
144
- Since <a href="HTTP.html#M000124">Net::HTTP.Proxy</a> returns <a
145
- href="HTTP.html">Net::HTTP</a> itself when proxy_addr is nil, there&#8217;s
146
- no need to change code if there&#8217;s proxy or not.
147
- </p>
148
- <p>
149
- There are two additional parameters in <a
150
- href="HTTP.html#M000124">Net::HTTP.Proxy</a> which allow to specify proxy
151
- user name and password:
152
- </p>
153
- <pre>
154
- Net::HTTP::Proxy(proxy_addr, proxy_port, proxy_user = nil, proxy_pass = nil)
155
- </pre>
156
- <p>
157
- You may use them to work with authorization-enabled proxies:
158
- </p>
159
- <pre>
160
- require 'net/http'
161
- require 'uri'
162
-
163
- proxy_host = 'your.proxy.host'
164
- proxy_port = 8080
165
- uri = URI.parse(ENV['http_proxy'])
166
- proxy_user, proxy_pass = uri.userinfo.split(/:/) if uri.userinfo
167
- Net::HTTP::Proxy(proxy_host, proxy_port,
168
- proxy_user, proxy_pass).start('www.example.com') {|http|
169
- # always connect to your.proxy.addr:8080 using specified username and password
170
- :
171
- }
172
- </pre>
173
- <p>
174
- Note that net/http never rely on HTTP_PROXY environment variable. If you
175
- want to use proxy, set it explicitly.
176
- </p>
177
- <h3>Following Redirection</h3>
178
- <pre>
179
- require 'net/http'
180
- require 'uri'
181
-
182
- def fetch( uri_str, limit = 10 )
183
- # You should choose better exception.
184
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
185
-
186
- response = Net::HTTP.get_response(URI.parse(uri_str))
187
- case response
188
- when Net::HTTPSuccess then response
189
- when Net::HTTPRedirection then fetch(response['location'], limit - 1)
190
- else
191
- response.error!
192
- end
193
- end
194
-
195
- print fetch('http://www.ruby-lang.org')
196
- </pre>
197
- <p>
198
- Net::HTTPSuccess and Net::HTTPRedirection is a <a
199
- href="HTTPResponse.html">HTTPResponse</a> class. All <a
200
- href="HTTPResponse.html">HTTPResponse</a> objects belong to its own
201
- response class which indicate <a href="HTTP.html">HTTP</a> result status.
202
- For details of response classes, see section &quot;<a
203
- href="HTTP.html">HTTP</a> Response Classes&quot;.
204
- </p>
205
- <h3>Basic Authentication</h3>
206
- <pre>
207
- require 'net/http'
208
-
209
- Net::HTTP.start('www.example.com') {|http|
210
- req = Net::HTTP::Get.new('/secret-page.html')
211
- req.basic_auth 'account', 'password'
212
- response = http.request(req)
213
- print response.body
214
- }
215
- </pre>
216
- <h3><a href="HTTP.html">HTTP</a> Response Classes</h3>
217
- <p>
218
- TODO: write me.
219
- </p>
220
- <h2>Switching <a href="HTTP.html">Net::HTTP</a> versions</h2>
221
- <p>
222
- You can use net/http.rb 1.1 features (bundled with Ruby 1.6) by calling <a
223
- href="HTTP.html#M000104">HTTP.version_1_1</a>. Calling <a
224
- href="HTTP.html#M000103">Net::HTTP.version_1_2</a> allows you to use 1.2
225
- features again.
226
- </p>
227
- <pre>
228
- # example
229
- Net::HTTP.start {|http1| ...(http1 has 1.2 features)... }
230
-
231
- Net::HTTP.version_1_1
232
- Net::HTTP.start {|http2| ...(http2 has 1.1 features)... }
233
-
234
- Net::HTTP.version_1_2
235
- Net::HTTP.start {|http3| ...(http3 has 1.2 features)... }
236
- </pre>
237
- <p>
238
- This function is NOT thread-safe.
239
- </p>
240
-
241
- </div>
242
-
243
-
244
- </div>
245
-
246
- <div id="method-list">
247
- <h3 class="section-bar">Methods</h3>
248
-
249
- <div class="name-list">
250
- <a href="#M000124">Proxy</a>&nbsp;&nbsp;
251
- <a href="#M000120">active?</a>&nbsp;&nbsp;
252
- <a href="#M000143">copy</a>&nbsp;&nbsp;
253
- <a href="#M000110">default_port</a>&nbsp;&nbsp;
254
- <a href="#M000141">delete</a>&nbsp;&nbsp;
255
- <a href="#M000123">finish</a>&nbsp;&nbsp;
256
- <a href="#M000133">get</a>&nbsp;&nbsp;
257
- <a href="#M000108">get</a>&nbsp;&nbsp;
258
- <a href="#M000149">get2</a>&nbsp;&nbsp;
259
- <a href="#M000107">get_print</a>&nbsp;&nbsp;
260
- <a href="#M000109">get_response</a>&nbsp;&nbsp;
261
- <a href="#M000134">head</a>&nbsp;&nbsp;
262
- <a href="#M000150">head2</a>&nbsp;&nbsp;
263
- <a href="#M000111">http_default_port</a>&nbsp;&nbsp;
264
- <a href="#M000112">https_default_port</a>&nbsp;&nbsp;
265
- <a href="#M000116">inspect</a>&nbsp;&nbsp;
266
- <a href="#M000137">lock</a>&nbsp;&nbsp;
267
- <a href="#M000144">mkcol</a>&nbsp;&nbsp;
268
- <a href="#M000142">move</a>&nbsp;&nbsp;
269
- <a href="#M000115">new</a>&nbsp;&nbsp;
270
- <a href="#M000114">new</a>&nbsp;&nbsp;
271
- <a href="#M000139">options</a>&nbsp;&nbsp;
272
- <a href="#M000161">peer_cert</a>&nbsp;&nbsp;
273
- <a href="#M000135">post</a>&nbsp;&nbsp;
274
- <a href="#M000151">post2</a>&nbsp;&nbsp;
275
- <a href="#M000140">propfind</a>&nbsp;&nbsp;
276
- <a href="#M000136">proppatch</a>&nbsp;&nbsp;
277
- <a href="#M000126">proxy?</a>&nbsp;&nbsp;
278
- <a href="#M000127">proxy_address</a>&nbsp;&nbsp;
279
- <a href="#M000125">proxy_class?</a>&nbsp;&nbsp;
280
- <a href="#M000130">proxy_pass</a>&nbsp;&nbsp;
281
- <a href="#M000128">proxy_port</a>&nbsp;&nbsp;
282
- <a href="#M000129">proxy_user</a>&nbsp;&nbsp;
283
- <a href="#M000131">proxyaddr</a>&nbsp;&nbsp;
284
- <a href="#M000132">proxyport</a>&nbsp;&nbsp;
285
- <a href="#M000118">read_timeout=</a>&nbsp;&nbsp;
286
- <a href="#M000153">request</a>&nbsp;&nbsp;
287
- <a href="#M000146">request_get</a>&nbsp;&nbsp;
288
- <a href="#M000147">request_head</a>&nbsp;&nbsp;
289
- <a href="#M000148">request_post</a>&nbsp;&nbsp;
290
- <a href="#M000152">send_request</a>&nbsp;&nbsp;
291
- <a href="#M000117">set_debug_output</a>&nbsp;&nbsp;
292
- <a href="#M000157">ssl_context_accessor</a>&nbsp;&nbsp;
293
- <a href="#M000158">ssl_timeout</a>&nbsp;&nbsp;
294
- <a href="#M000159">ssl_timeout=</a>&nbsp;&nbsp;
295
- <a href="#M000113">start</a>&nbsp;&nbsp;
296
- <a href="#M000122">start</a>&nbsp;&nbsp;
297
- <a href="#M000119">started?</a>&nbsp;&nbsp;
298
- <a href="#M000160">timeout=</a>&nbsp;&nbsp;
299
- <a href="#M000145">trace</a>&nbsp;&nbsp;
300
- <a href="#M000138">unlock</a>&nbsp;&nbsp;
301
- <a href="#M000155">use_ssl</a>&nbsp;&nbsp;
302
- <a href="#M000156">use_ssl=</a>&nbsp;&nbsp;
303
- <a href="#M000154">use_ssl?</a>&nbsp;&nbsp;
304
- <a href="#M000121">use_ssl?</a>&nbsp;&nbsp;
305
- <a href="#M000104">version_1_1</a>&nbsp;&nbsp;
306
- <a href="#M000106">version_1_1?</a>&nbsp;&nbsp;
307
- <a href="#M000103">version_1_2</a>&nbsp;&nbsp;
308
- <a href="#M000105">version_1_2?</a>&nbsp;&nbsp;
309
- </div>
310
- </div>
311
-
312
- </div>
313
-
314
-
315
- <!-- if includes -->
316
-
317
- <div id="section">
318
-
319
- <div id="class-list">
320
- <h3 class="section-bar">Classes and Modules</h3>
321
-
322
- Class <a href="HTTP/Copy.html" class="link">Net::HTTP::Copy</a><br />
323
- Class <a href="HTTP/Delete.html" class="link">Net::HTTP::Delete</a><br />
324
- Class <a href="HTTP/Get.html" class="link">Net::HTTP::Get</a><br />
325
- Class <a href="HTTP/Head.html" class="link">Net::HTTP::Head</a><br />
326
- Class <a href="HTTP/Lock.html" class="link">Net::HTTP::Lock</a><br />
327
- Class <a href="HTTP/Mkcol.html" class="link">Net::HTTP::Mkcol</a><br />
328
- Class <a href="HTTP/Move.html" class="link">Net::HTTP::Move</a><br />
329
- Class <a href="HTTP/Options.html" class="link">Net::HTTP::Options</a><br />
330
- Class <a href="HTTP/Post.html" class="link">Net::HTTP::Post</a><br />
331
- Class <a href="HTTP/Propfind.html" class="link">Net::HTTP::Propfind</a><br />
332
- Class <a href="HTTP/Proppatch.html" class="link">Net::HTTP::Proppatch</a><br />
333
- Class <a href="HTTP/Put.html" class="link">Net::HTTP::Put</a><br />
334
- Class <a href="HTTP/Trace.html" class="link">Net::HTTP::Trace</a><br />
335
- Class <a href="HTTP/Unlock.html" class="link">Net::HTTP::Unlock</a><br />
336
-
337
- </div>
338
-
339
-
340
- <div id="aliases-list">
341
- <h3 class="section-bar">External Aliases</h3>
342
-
343
- <div class="name-list">
344
- <table summary="aliases">
345
- <tr class="top-aligned-row context-row">
346
- <td class="context-item-name">version_1_1?</td>
347
- <td>-></td>
348
- <td class="context-item-value">is_version_1_1?</td>
349
- </tr>
350
- <tr class="top-aligned-row context-row">
351
- <td class="context-item-name">version_1_2?</td>
352
- <td>-></td>
353
- <td class="context-item-value">is_version_1_2?</td>
354
- </tr>
355
- <tr class="top-aligned-row context-row">
356
- <td class="context-item-name">new</td>
357
- <td>-></td>
358
- <td class="context-item-value">newobj</td>
359
- </tr>
360
- <tr class="top-aligned-row context-row">
361
- <td class="context-item-name">request_put</td>
362
- <td>-></td>
363
- <td class="context-item-value">put2</td>
364
- </tr>
365
- </table>
366
- </div>
367
- </div>
368
-
369
-
370
- <div id="attribute-list">
371
- <h3 class="section-bar">Attributes</h3>
372
-
373
- <div class="name-list">
374
- <table>
375
- <tr class="top-aligned-row context-row">
376
- <td class="context-item-name">address</td>
377
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
378
- <td class="context-item-desc">
379
- The host name to connect to.
380
-
381
- </td>
382
- </tr>
383
- <tr class="top-aligned-row context-row">
384
- <td class="context-item-name">close_on_empty_response</td>
385
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
386
- <td class="context-item-desc"></td>
387
- </tr>
388
- <tr class="top-aligned-row context-row">
389
- <td class="context-item-name">open_timeout</td>
390
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
391
- <td class="context-item-desc">
392
- Seconds to wait until connection is opened. If the <a
393
- href="HTTP.html">HTTP</a> object cannot open a connection in this many
394
- seconds, it raises a TimeoutError exception.
395
-
396
- </td>
397
- </tr>
398
- <tr class="top-aligned-row context-row">
399
- <td class="context-item-name">port</td>
400
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
401
- <td class="context-item-desc">
402
- The port number to connect to.
403
-
404
- </td>
405
- </tr>
406
- <tr class="top-aligned-row context-row">
407
- <td class="context-item-name">proxy_address</td>
408
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
409
- <td class="context-item-desc"></td>
410
- </tr>
411
- <tr class="top-aligned-row context-row">
412
- <td class="context-item-name">proxy_pass</td>
413
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
414
- <td class="context-item-desc"></td>
415
- </tr>
416
- <tr class="top-aligned-row context-row">
417
- <td class="context-item-name">proxy_port</td>
418
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
419
- <td class="context-item-desc"></td>
420
- </tr>
421
- <tr class="top-aligned-row context-row">
422
- <td class="context-item-name">proxy_user</td>
423
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
424
- <td class="context-item-desc"></td>
425
- </tr>
426
- <tr class="top-aligned-row context-row">
427
- <td class="context-item-name">read_timeout</td>
428
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
429
- <td class="context-item-desc">
430
- Seconds to wait until reading one block (by one read(2) call). If the <a
431
- href="HTTP.html">HTTP</a> object cannot open a connection in this many
432
- seconds, it raises a TimeoutError exception.
433
-
434
- </td>
435
- </tr>
436
- </table>
437
- </div>
438
- </div>
439
-
440
-
441
-
442
- <!-- if method_list -->
443
- <div id="methods">
444
- <h3 class="section-bar">Public Class methods</h3>
445
-
446
- <div id="method-M000124" class="method-detail">
447
- <a name="M000124"></a>
448
-
449
- <div class="method-heading">
450
- <a href="HTTP.src/M000124.html" target="Code" class="method-signature"
451
- onclick="popupCode('HTTP.src/M000124.html');return false;">
452
- <span class="method-name">Proxy</span><span class="method-args">(p_addr, p_port = nil, p_user = nil, p_pass = nil)</span>
453
- </a>
454
- </div>
455
-
456
- <div class="method-description">
457
- <p>
458
- Creates an <a href="HTTP.html">HTTP</a> proxy class. Arguments are
459
- address/port of proxy host and username/password if authorization on proxy
460
- server is required. You can replace the <a href="HTTP.html">HTTP</a> class
461
- with created proxy class.
462
- </p>
463
- <p>
464
- If ADDRESS is nil, this method returns self (<a
465
- href="HTTP.html">Net::HTTP</a>).
466
- </p>
467
- <pre>
468
- # Example
469
- proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
470
- :
471
- proxy_class.start('www.ruby-lang.org') {|http|
472
- # connecting proxy.foo.org:8080
473
- :
474
- }
475
- </pre>
476
- </div>
477
- </div>
478
-
479
- <div id="method-M000110" class="method-detail">
480
- <a name="M000110"></a>
481
-
482
- <div class="method-heading">
483
- <a href="HTTP.src/M000110.html" target="Code" class="method-signature"
484
- onclick="popupCode('HTTP.src/M000110.html');return false;">
485
- <span class="method-name">default_port</span><span class="method-args">()</span>
486
- </a>
487
- </div>
488
-
489
- <div class="method-description">
490
- <p>
491
- The default port to use for <a href="HTTP.html">HTTP</a> requests; defaults
492
- to 80.
493
- </p>
494
- </div>
495
- </div>
496
-
497
- <div id="method-M000108" class="method-detail">
498
- <a name="M000108"></a>
499
-
500
- <div class="method-heading">
501
- <a href="HTTP.src/M000108.html" target="Code" class="method-signature"
502
- onclick="popupCode('HTTP.src/M000108.html');return false;">
503
- <span class="method-name">get</span><span class="method-args">(arg1, arg2 = nil, arg3 = nil)</span>
504
- </a>
505
- </div>
506
-
507
- <div class="method-description">
508
- <p>
509
- Send a GET request to the target and return the response as a string. The
510
- target can either be specified as (<tt>uri</tt>), or as (<tt>host</tt>,
511
- <tt>path</tt>, <tt>port</tt> = 80); so:
512
- </p>
513
- <pre>
514
- print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
515
- </pre>
516
- <p>
517
- or:
518
- </p>
519
- <pre>
520
- print Net::HTTP.get('www.example.com', '/index.html')
521
- </pre>
522
- </div>
523
- </div>
524
-
525
- <div id="method-M000107" class="method-detail">
526
- <a name="M000107"></a>
527
-
528
- <div class="method-heading">
529
- <a href="HTTP.src/M000107.html" target="Code" class="method-signature"
530
- onclick="popupCode('HTTP.src/M000107.html');return false;">
531
- <span class="method-name">get_print</span><span class="method-args">(arg1, arg2 = nil, port = nil)</span>
532
- </a>
533
- </div>
534
-
535
- <div class="method-description">
536
- <p>
537
- <a href="HTTP/Get.html">Get</a> body from target and output it to
538
- +$stdout+. The target can either be specified as (<tt>uri</tt>), or as
539
- (<tt>host</tt>, <tt>path</tt>, <tt>port</tt> = 80); so:
540
- </p>
541
- <pre>
542
- Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
543
- </pre>
544
- <p>
545
- or:
546
- </p>
547
- <pre>
548
- Net::HTTP.get_print('www.example.com', '/index.html')
549
- </pre>
550
- </div>
551
- </div>
552
-
553
- <div id="method-M000109" class="method-detail">
554
- <a name="M000109"></a>
555
-
556
- <div class="method-heading">
557
- <a href="HTTP.src/M000109.html" target="Code" class="method-signature"
558
- onclick="popupCode('HTTP.src/M000109.html');return false;">
559
- <span class="method-name">get_response</span><span class="method-args">(arg1, arg2 = nil, arg3 = nil)</span>
560
- </a>
561
- </div>
562
-
563
- <div class="method-description">
564
- <p>
565
- Send a GET request to the target and return the response as a <a
566
- href="HTTPResponse.html">Net::HTTPResponse</a> object. The target can
567
- either be specified as (<tt>uri</tt>), or as (<tt>host</tt>, <tt>path</tt>,
568
- <tt>port</tt> = 80); so:
569
- </p>
570
- <pre>
571
- res = Net::HTTP.get_response(URI.parse('http://www.example.com/index.html'))
572
- print res.body
573
- </pre>
574
- <p>
575
- or:
576
- </p>
577
- <pre>
578
- res = Net::HTTP.get_response('www.example.com', '/index.html')
579
- print res.body
580
- </pre>
581
- </div>
582
- </div>
583
-
584
- <div id="method-M000111" class="method-detail">
585
- <a name="M000111"></a>
586
-
587
- <div class="method-heading">
588
- <a href="HTTP.src/M000111.html" target="Code" class="method-signature"
589
- onclick="popupCode('HTTP.src/M000111.html');return false;">
590
- <span class="method-name">http_default_port</span><span class="method-args">()</span>
591
- </a>
592
- </div>
593
-
594
- <div class="method-description">
595
- <p>
596
- The default port to use for <a href="HTTP.html">HTTP</a> requests; defaults
597
- to 80.
598
- </p>
599
- </div>
600
- </div>
601
-
602
- <div id="method-M000112" class="method-detail">
603
- <a name="M000112"></a>
604
-
605
- <div class="method-heading">
606
- <a href="HTTP.src/M000112.html" target="Code" class="method-signature"
607
- onclick="popupCode('HTTP.src/M000112.html');return false;">
608
- <span class="method-name">https_default_port</span><span class="method-args">()</span>
609
- </a>
610
- </div>
611
-
612
- <div class="method-description">
613
- <p>
614
- The default port to use for HTTPS requests; defaults to 443.
615
- </p>
616
- </div>
617
- </div>
618
-
619
- <div id="method-M000115" class="method-detail">
620
- <a name="M000115"></a>
621
-
622
- <div class="method-heading">
623
- <a href="HTTP.src/M000115.html" target="Code" class="method-signature"
624
- onclick="popupCode('HTTP.src/M000115.html');return false;">
625
- <span class="method-name">new</span><span class="method-args">(address, port = nil)</span>
626
- </a>
627
- </div>
628
-
629
- <div class="method-description">
630
- <p>
631
- Creates a new <a href="HTTP.html">Net::HTTP</a> object for the specified
632
- <tt>address</tt>. This method does not open the TCP connection.
633
- </p>
634
- </div>
635
- </div>
636
-
637
- <div id="method-M000114" class="method-detail">
638
- <a name="M000114"></a>
639
-
640
- <div class="method-heading">
641
- <a href="HTTP.src/M000114.html" target="Code" class="method-signature"
642
- onclick="popupCode('HTTP.src/M000114.html');return false;">
643
- <span class="method-name">new</span><span class="method-args">(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil)</span>
644
- </a>
645
- </div>
646
-
647
- <div class="method-description">
648
- <p>
649
- Creates a new <a href="HTTP.html">Net::HTTP</a> object. If
650
- <tt>proxy_addr</tt> is given, creates an <a href="HTTP.html">Net::HTTP</a>
651
- object with proxy support. This method does not open the TCP connection.
652
- </p>
653
- </div>
654
- </div>
655
-
656
- <div id="method-M000125" class="method-detail">
657
- <a name="M000125"></a>
658
-
659
- <div class="method-heading">
660
- <a href="HTTP.src/M000125.html" target="Code" class="method-signature"
661
- onclick="popupCode('HTTP.src/M000125.html');return false;">
662
- <span class="method-name">proxy_class?</span><span class="method-args">()</span>
663
- </a>
664
- </div>
665
-
666
- <div class="method-description">
667
- <p>
668
- returns true if self is a class which was created by HTTP::Proxy.
669
- </p>
670
- </div>
671
- </div>
672
-
673
- <div id="method-M000157" class="method-detail">
674
- <a name="M000157"></a>
675
-
676
- <div class="method-heading">
677
- <a href="HTTP.src/M000157.html" target="Code" class="method-signature"
678
- onclick="popupCode('HTTP.src/M000157.html');return false;">
679
- <span class="method-name">ssl_context_accessor</span><span class="method-args">(name)</span>
680
- </a>
681
- </div>
682
-
683
- <div class="method-description">
684
- </div>
685
- </div>
686
-
687
- <div id="method-M000113" class="method-detail">
688
- <a name="M000113"></a>
689
-
690
- <div class="method-heading">
691
- <a href="HTTP.src/M000113.html" target="Code" class="method-signature"
692
- onclick="popupCode('HTTP.src/M000113.html');return false;">
693
- <span class="method-name">start</span><span class="method-args">(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) {|+http+| ...}</span>
694
- </a>
695
- </div>
696
-
697
- <div class="method-description">
698
- <p>
699
- creates a new <a href="HTTP.html">Net::HTTP</a> object and opens its TCP
700
- connection and <a href="HTTP.html">HTTP</a> session. If the optional block
701
- is given, the newly created <a href="HTTP.html">Net::HTTP</a> object is
702
- passed to it and closed when the block finishes. In this case, the return
703
- value of this method is the return value of the block. If no block is
704
- given, the return value of this method is the newly created <a
705
- href="HTTP.html">Net::HTTP</a> object itself, and the caller is responsible
706
- for closing it upon completion.
707
- </p>
708
- </div>
709
- </div>
710
-
711
- <div id="method-M000104" class="method-detail">
712
- <a name="M000104"></a>
713
-
714
- <div class="method-heading">
715
- <a href="HTTP.src/M000104.html" target="Code" class="method-signature"
716
- onclick="popupCode('HTTP.src/M000104.html');return false;">
717
- <span class="method-name">version_1_1</span><span class="method-args">()</span>
718
- </a>
719
- </div>
720
-
721
- <div class="method-description">
722
- <p>
723
- Turns on net/http 1.1 (ruby 1.6) features. Defaults to OFF in ruby 1.8.
724
- </p>
725
- </div>
726
- </div>
727
-
728
- <div id="method-M000106" class="method-detail">
729
- <a name="M000106"></a>
730
-
731
- <div class="method-heading">
732
- <a href="HTTP.src/M000106.html" target="Code" class="method-signature"
733
- onclick="popupCode('HTTP.src/M000106.html');return false;">
734
- <span class="method-name">version_1_1?</span><span class="method-args">()</span>
735
- </a>
736
- </div>
737
-
738
- <div class="method-description">
739
- <p>
740
- true if net/http is in version 1.1 compatible mode. Defaults to true.
741
- </p>
742
- </div>
743
- </div>
744
-
745
- <div id="method-M000103" class="method-detail">
746
- <a name="M000103"></a>
747
-
748
- <div class="method-heading">
749
- <a href="HTTP.src/M000103.html" target="Code" class="method-signature"
750
- onclick="popupCode('HTTP.src/M000103.html');return false;">
751
- <span class="method-name">version_1_2</span><span class="method-args">()</span>
752
- </a>
753
- </div>
754
-
755
- <div class="method-description">
756
- <p>
757
- Turns on net/http 1.2 (ruby 1.8) features. Defaults to ON in ruby 1.8.
758
- </p>
759
- <p>
760
- I strongly recommend to call this method always.
761
- </p>
762
- <pre>
763
- require 'net/http'
764
- Net::HTTP.version_1_2
765
- </pre>
766
- </div>
767
- </div>
768
-
769
- <div id="method-M000105" class="method-detail">
770
- <a name="M000105"></a>
771
-
772
- <div class="method-heading">
773
- <a href="HTTP.src/M000105.html" target="Code" class="method-signature"
774
- onclick="popupCode('HTTP.src/M000105.html');return false;">
775
- <span class="method-name">version_1_2?</span><span class="method-args">()</span>
776
- </a>
777
- </div>
778
-
779
- <div class="method-description">
780
- <p>
781
- true if net/http is in version 1.2 mode. Defaults to true.
782
- </p>
783
- </div>
784
- </div>
785
-
786
- <h3 class="section-bar">Public Instance methods</h3>
787
-
788
- <div id="method-M000120" class="method-detail">
789
- <a name="M000120"></a>
790
-
791
- <div class="method-heading">
792
- <span class="method-name">active?</span><span class="method-args">()</span>
793
- </div>
794
-
795
- <div class="method-description">
796
- <p>
797
- Alias for <a href="HTTP.html#M000119">started?</a>
798
- </p>
799
- </div>
800
- </div>
801
-
802
- <div id="method-M000143" class="method-detail">
803
- <a name="M000143"></a>
804
-
805
- <div class="method-heading">
806
- <a href="HTTP.src/M000143.html" target="Code" class="method-signature"
807
- onclick="popupCode('HTTP.src/M000143.html');return false;">
808
- <span class="method-name">copy</span><span class="method-args">(path, initheader = nil)</span>
809
- </a>
810
- </div>
811
-
812
- <div class="method-description">
813
- <p>
814
- Sends a COPY request to the <tt>path</tt> and gets a response, as an <a
815
- href="HTTPResponse.html">HTTPResponse</a> object.
816
- </p>
817
- </div>
818
- </div>
819
-
820
- <div id="method-M000141" class="method-detail">
821
- <a name="M000141"></a>
822
-
823
- <div class="method-heading">
824
- <a href="HTTP.src/M000141.html" target="Code" class="method-signature"
825
- onclick="popupCode('HTTP.src/M000141.html');return false;">
826
- <span class="method-name">delete</span><span class="method-args">(path, initheader = {'Depth' =&gt; 'Infinity'})</span>
827
- </a>
828
- </div>
829
-
830
- <div class="method-description">
831
- <p>
832
- Sends a DELETE request to the <tt>path</tt> and gets a response, as an <a
833
- href="HTTPResponse.html">HTTPResponse</a> object.
834
- </p>
835
- </div>
836
- </div>
837
-
838
- <div id="method-M000123" class="method-detail">
839
- <a name="M000123"></a>
840
-
841
- <div class="method-heading">
842
- <a href="HTTP.src/M000123.html" target="Code" class="method-signature"
843
- onclick="popupCode('HTTP.src/M000123.html');return false;">
844
- <span class="method-name">finish</span><span class="method-args">()</span>
845
- </a>
846
- </div>
847
-
848
- <div class="method-description">
849
- <p>
850
- Finishes <a href="HTTP.html">HTTP</a> session and closes TCP connection.
851
- Raises IOError if not started.
852
- </p>
853
- </div>
854
- </div>
855
-
856
- <div id="method-M000133" class="method-detail">
857
- <a name="M000133"></a>
858
-
859
- <div class="method-heading">
860
- <a href="HTTP.src/M000133.html" target="Code" class="method-signature"
861
- onclick="popupCode('HTTP.src/M000133.html');return false;">
862
- <span class="method-name">get</span><span class="method-args">(path, initheader = nil, dest = nil) {|+body_segment+| ...}</span>
863
- </a>
864
- </div>
865
-
866
- <div class="method-description">
867
- <p>
868
- Gets data from <tt>path</tt> on the connected-to host. <tt>header</tt> must
869
- be a Hash like { &#8216;Accept&#8217; =&gt; &#8217;*/*&#8217;, &#8230; }.
870
- </p>
871
- <p>
872
- In version 1.1 (ruby 1.6), this method returns a pair of objects, a <a
873
- href="HTTPResponse.html">Net::HTTPResponse</a> object and the entity body
874
- string. In version 1.2 (ruby 1.8), this method returns a <a
875
- href="HTTPResponse.html">Net::HTTPResponse</a> object.
876
- </p>
877
- <p>
878
- If called with a block, yields each fragment of the entity body in turn as
879
- a string as it is read from the socket. Note that in this case, the
880
- returned response object will <b>not</b> contain a (meaningful) body.
881
- </p>
882
- <p>
883
- <tt>dest</tt> argument is obsolete. It still works but you must not use it.
884
- </p>
885
- <p>
886
- In version 1.1, this method might raise an exception for 3xx (redirect). In
887
- this case you can get a <a href="HTTPResponse.html">HTTPResponse</a> object
888
- by &quot;anException.response&quot;.
889
- </p>
890
- <p>
891
- In version 1.2, this method never raises exception.
892
- </p>
893
- <pre>
894
- # version 1.1 (bundled with Ruby 1.6)
895
- response, body = http.get('/index.html')
896
-
897
- # version 1.2 (bundled with Ruby 1.8 or later)
898
- response = http.get('/index.html')
899
-
900
- # using block
901
- File.open('result.txt', 'w') {|f|
902
- http.get('/~foo/') do |str|
903
- f.write str
904
- end
905
- }
906
- </pre>
907
- </div>
908
- </div>
909
-
910
- <div id="method-M000149" class="method-detail">
911
- <a name="M000149"></a>
912
-
913
- <div class="method-heading">
914
- <span class="method-name">get2</span><span class="method-args">(path, initheader = nil)</span>
915
- </div>
916
-
917
- <div class="method-description">
918
- <p>
919
- Alias for <a href="HTTP.html#M000146">request_get</a>
920
- </p>
921
- </div>
922
- </div>
923
-
924
- <div id="method-M000134" class="method-detail">
925
- <a name="M000134"></a>
926
-
927
- <div class="method-heading">
928
- <a href="HTTP.src/M000134.html" target="Code" class="method-signature"
929
- onclick="popupCode('HTTP.src/M000134.html');return false;">
930
- <span class="method-name">head</span><span class="method-args">(path, initheader = nil)</span>
931
- </a>
932
- </div>
933
-
934
- <div class="method-description">
935
- <p>
936
- Gets only the header from <tt>path</tt> on the connected-to host.
937
- <tt>header</tt> is a Hash like { &#8216;Accept&#8217; =&gt;
938
- &#8217;*/*&#8217;, &#8230; }.
939
- </p>
940
- <p>
941
- This method returns a <a href="HTTPResponse.html">Net::HTTPResponse</a>
942
- object.
943
- </p>
944
- <p>
945
- In version 1.1, this method might raise an exception for 3xx (redirect). On
946
- the case you can get a <a href="HTTPResponse.html">HTTPResponse</a> object
947
- by &quot;anException.response&quot;. In version 1.2, this method never
948
- raises an exception.
949
- </p>
950
- <pre>
951
- response = nil
952
- Net::HTTP.start('some.www.server', 80) {|http|
953
- response = http.head('/index.html')
954
- }
955
- p response['content-type']
956
- </pre>
957
- </div>
958
- </div>
959
-
960
- <div id="method-M000150" class="method-detail">
961
- <a name="M000150"></a>
962
-
963
- <div class="method-heading">
964
- <span class="method-name">head2</span><span class="method-args">(path, initheader = nil, &amp;block)</span>
965
- </div>
966
-
967
- <div class="method-description">
968
- <p>
969
- Alias for <a href="HTTP.html#M000147">request_head</a>
970
- </p>
971
- </div>
972
- </div>
973
-
974
- <div id="method-M000116" class="method-detail">
975
- <a name="M000116"></a>
976
-
977
- <div class="method-heading">
978
- <a href="HTTP.src/M000116.html" target="Code" class="method-signature"
979
- onclick="popupCode('HTTP.src/M000116.html');return false;">
980
- <span class="method-name">inspect</span><span class="method-args">()</span>
981
- </a>
982
- </div>
983
-
984
- <div class="method-description">
985
- </div>
986
- </div>
987
-
988
- <div id="method-M000137" class="method-detail">
989
- <a name="M000137"></a>
990
-
991
- <div class="method-heading">
992
- <a href="HTTP.src/M000137.html" target="Code" class="method-signature"
993
- onclick="popupCode('HTTP.src/M000137.html');return false;">
994
- <span class="method-name">lock</span><span class="method-args">(path, body, initheader = nil)</span>
995
- </a>
996
- </div>
997
-
998
- <div class="method-description">
999
- <p>
1000
- Sends a LOCK request to the <tt>path</tt> and gets a response, as an <a
1001
- href="HTTPResponse.html">HTTPResponse</a> object.
1002
- </p>
1003
- </div>
1004
- </div>
1005
-
1006
- <div id="method-M000144" class="method-detail">
1007
- <a name="M000144"></a>
1008
-
1009
- <div class="method-heading">
1010
- <a href="HTTP.src/M000144.html" target="Code" class="method-signature"
1011
- onclick="popupCode('HTTP.src/M000144.html');return false;">
1012
- <span class="method-name">mkcol</span><span class="method-args">(path, body = nil, initheader = nil)</span>
1013
- </a>
1014
- </div>
1015
-
1016
- <div class="method-description">
1017
- <p>
1018
- Sends a MKCOL request to the <tt>path</tt> and gets a response, as an <a
1019
- href="HTTPResponse.html">HTTPResponse</a> object.
1020
- </p>
1021
- </div>
1022
- </div>
1023
-
1024
- <div id="method-M000142" class="method-detail">
1025
- <a name="M000142"></a>
1026
-
1027
- <div class="method-heading">
1028
- <a href="HTTP.src/M000142.html" target="Code" class="method-signature"
1029
- onclick="popupCode('HTTP.src/M000142.html');return false;">
1030
- <span class="method-name">move</span><span class="method-args">(path, initheader = nil)</span>
1031
- </a>
1032
- </div>
1033
-
1034
- <div class="method-description">
1035
- <p>
1036
- Sends a MOVE request to the <tt>path</tt> and gets a response, as an <a
1037
- href="HTTPResponse.html">HTTPResponse</a> object.
1038
- </p>
1039
- </div>
1040
- </div>
1041
-
1042
- <div id="method-M000139" class="method-detail">
1043
- <a name="M000139"></a>
1044
-
1045
- <div class="method-heading">
1046
- <a href="HTTP.src/M000139.html" target="Code" class="method-signature"
1047
- onclick="popupCode('HTTP.src/M000139.html');return false;">
1048
- <span class="method-name">options</span><span class="method-args">(path, initheader = nil)</span>
1049
- </a>
1050
- </div>
1051
-
1052
- <div class="method-description">
1053
- <p>
1054
- Sends a OPTIONS request to the <tt>path</tt> and gets a response, as an <a
1055
- href="HTTPResponse.html">HTTPResponse</a> object.
1056
- </p>
1057
- </div>
1058
- </div>
1059
-
1060
- <div id="method-M000161" class="method-detail">
1061
- <a name="M000161"></a>
1062
-
1063
- <div class="method-heading">
1064
- <a href="HTTP.src/M000161.html" target="Code" class="method-signature"
1065
- onclick="popupCode('HTTP.src/M000161.html');return false;">
1066
- <span class="method-name">peer_cert</span><span class="method-args">()</span>
1067
- </a>
1068
- </div>
1069
-
1070
- <div class="method-description">
1071
- </div>
1072
- </div>
1073
-
1074
- <div id="method-M000135" class="method-detail">
1075
- <a name="M000135"></a>
1076
-
1077
- <div class="method-heading">
1078
- <a href="HTTP.src/M000135.html" target="Code" class="method-signature"
1079
- onclick="popupCode('HTTP.src/M000135.html');return false;">
1080
- <span class="method-name">post</span><span class="method-args">(path, data, initheader = nil, dest = nil) {|+body_segment+| ...}</span>
1081
- </a>
1082
- </div>
1083
-
1084
- <div class="method-description">
1085
- <p>
1086
- Posts <tt>data</tt> (must be a String) to <tt>path</tt>. <tt>header</tt>
1087
- must be a Hash like { &#8216;Accept&#8217; =&gt; &#8217;*/*&#8217;, &#8230;
1088
- }.
1089
- </p>
1090
- <p>
1091
- In version 1.1 (ruby 1.6), this method returns a pair of objects, a <a
1092
- href="HTTPResponse.html">Net::HTTPResponse</a> object and an entity body
1093
- string. In version 1.2 (ruby 1.8), this method returns a <a
1094
- href="HTTPResponse.html">Net::HTTPResponse</a> object.
1095
- </p>
1096
- <p>
1097
- If called with a block, yields each fragment of the entity body in turn as
1098
- a string as it are read from the socket. Note that in this case, the
1099
- returned response object will <b>not</b> contain a (meaningful) body.
1100
- </p>
1101
- <p>
1102
- <tt>dest</tt> is an alternative method of collecting the body. It must be
1103
- an object responding to the &quot;&lt;&lt;&quot; operator (such as a String
1104
- or an Array). Each fragment of the entity body will be
1105
- &quot;&lt;&lt;&quot;-ed in turn onto <tt>dest</tt> if provided, and it will
1106
- also become the body of the returned response object.
1107
- </p>
1108
- <p>
1109
- You must <b>not</b> provide both <tt>dest</tt> and a block; doing so will
1110
- result in an ArgumentError.
1111
- </p>
1112
- <p>
1113
- In version 1.1, this method might raise an exception for 3xx (redirect). In
1114
- this case you can get an <a href="HTTPResponse.html">HTTPResponse</a>
1115
- object by &quot;anException.response&quot;. In version 1.2, this method
1116
- never raises exception.
1117
- </p>
1118
- <pre>
1119
- # version 1.1
1120
- response, body = http.post('/cgi-bin/search.rb', 'query=foo')
1121
-
1122
- # version 1.2
1123
- response = http.post('/cgi-bin/search.rb', 'query=foo')
1124
-
1125
- # using block
1126
- File.open('result.txt', 'w') {|f|
1127
- http.post('/cgi-bin/search.rb', 'query=foo') do |str|
1128
- f.write str
1129
- end
1130
- }
1131
- </pre>
1132
- </div>
1133
- </div>
1134
-
1135
- <div id="method-M000151" class="method-detail">
1136
- <a name="M000151"></a>
1137
-
1138
- <div class="method-heading">
1139
- <span class="method-name">post2</span><span class="method-args">(path, data, initheader = nil)</span>
1140
- </div>
1141
-
1142
- <div class="method-description">
1143
- <p>
1144
- Alias for <a href="HTTP.html#M000148">request_post</a>
1145
- </p>
1146
- </div>
1147
- </div>
1148
-
1149
- <div id="method-M000140" class="method-detail">
1150
- <a name="M000140"></a>
1151
-
1152
- <div class="method-heading">
1153
- <a href="HTTP.src/M000140.html" target="Code" class="method-signature"
1154
- onclick="popupCode('HTTP.src/M000140.html');return false;">
1155
- <span class="method-name">propfind</span><span class="method-args">(path, body = nil, initheader = {'Depth' =&gt; '0'})</span>
1156
- </a>
1157
- </div>
1158
-
1159
- <div class="method-description">
1160
- <p>
1161
- Sends a PROPFIND request to the <tt>path</tt> and gets a response, as an <a
1162
- href="HTTPResponse.html">HTTPResponse</a> object.
1163
- </p>
1164
- </div>
1165
- </div>
1166
-
1167
- <div id="method-M000136" class="method-detail">
1168
- <a name="M000136"></a>
1169
-
1170
- <div class="method-heading">
1171
- <a href="HTTP.src/M000136.html" target="Code" class="method-signature"
1172
- onclick="popupCode('HTTP.src/M000136.html');return false;">
1173
- <span class="method-name">proppatch</span><span class="method-args">(path, body, initheader = nil)</span>
1174
- </a>
1175
- </div>
1176
-
1177
- <div class="method-description">
1178
- <p>
1179
- Sends a PROPPATCH request to the <tt>path</tt> and gets a response, as an
1180
- <a href="HTTPResponse.html">HTTPResponse</a> object.
1181
- </p>
1182
- </div>
1183
- </div>
1184
-
1185
- <div id="method-M000126" class="method-detail">
1186
- <a name="M000126"></a>
1187
-
1188
- <div class="method-heading">
1189
- <a href="HTTP.src/M000126.html" target="Code" class="method-signature"
1190
- onclick="popupCode('HTTP.src/M000126.html');return false;">
1191
- <span class="method-name">proxy?</span><span class="method-args">()</span>
1192
- </a>
1193
- </div>
1194
-
1195
- <div class="method-description">
1196
- <p>
1197
- True if self is a <a href="HTTP.html">HTTP</a> proxy class.
1198
- </p>
1199
- </div>
1200
- </div>
1201
-
1202
- <div id="method-M000127" class="method-detail">
1203
- <a name="M000127"></a>
1204
-
1205
- <div class="method-heading">
1206
- <a href="HTTP.src/M000127.html" target="Code" class="method-signature"
1207
- onclick="popupCode('HTTP.src/M000127.html');return false;">
1208
- <span class="method-name">proxy_address</span><span class="method-args">()</span>
1209
- </a>
1210
- </div>
1211
-
1212
- <div class="method-description">
1213
- <p>
1214
- Address of proxy host. If self does not use a proxy, nil.
1215
- </p>
1216
- </div>
1217
- </div>
1218
-
1219
- <div id="method-M000130" class="method-detail">
1220
- <a name="M000130"></a>
1221
-
1222
- <div class="method-heading">
1223
- <a href="HTTP.src/M000130.html" target="Code" class="method-signature"
1224
- onclick="popupCode('HTTP.src/M000130.html');return false;">
1225
- <span class="method-name">proxy_pass</span><span class="method-args">()</span>
1226
- </a>
1227
- </div>
1228
-
1229
- <div class="method-description">
1230
- <p>
1231
- User password for accessing proxy. If self does not use a proxy, nil.
1232
- </p>
1233
- </div>
1234
- </div>
1235
-
1236
- <div id="method-M000128" class="method-detail">
1237
- <a name="M000128"></a>
1238
-
1239
- <div class="method-heading">
1240
- <a href="HTTP.src/M000128.html" target="Code" class="method-signature"
1241
- onclick="popupCode('HTTP.src/M000128.html');return false;">
1242
- <span class="method-name">proxy_port</span><span class="method-args">()</span>
1243
- </a>
1244
- </div>
1245
-
1246
- <div class="method-description">
1247
- <p>
1248
- Port number of proxy host. If self does not use a proxy, nil.
1249
- </p>
1250
- </div>
1251
- </div>
1252
-
1253
- <div id="method-M000129" class="method-detail">
1254
- <a name="M000129"></a>
1255
-
1256
- <div class="method-heading">
1257
- <a href="HTTP.src/M000129.html" target="Code" class="method-signature"
1258
- onclick="popupCode('HTTP.src/M000129.html');return false;">
1259
- <span class="method-name">proxy_user</span><span class="method-args">()</span>
1260
- </a>
1261
- </div>
1262
-
1263
- <div class="method-description">
1264
- <p>
1265
- User name for accessing proxy. If self does not use a proxy, nil.
1266
- </p>
1267
- </div>
1268
- </div>
1269
-
1270
- <div id="method-M000131" class="method-detail">
1271
- <a name="M000131"></a>
1272
-
1273
- <div class="method-heading">
1274
- <span class="method-name">proxyaddr</span><span class="method-args">()</span>
1275
- </div>
1276
-
1277
- <div class="method-description">
1278
- <p>
1279
- Alias for <a href="HTTP.html#M000127">proxy_address</a>
1280
- </p>
1281
- </div>
1282
- </div>
1283
-
1284
- <div id="method-M000132" class="method-detail">
1285
- <a name="M000132"></a>
1286
-
1287
- <div class="method-heading">
1288
- <span class="method-name">proxyport</span><span class="method-args">()</span>
1289
- </div>
1290
-
1291
- <div class="method-description">
1292
- <p>
1293
- Alias for <a href="HTTP.html#M000128">proxy_port</a>
1294
- </p>
1295
- </div>
1296
- </div>
1297
-
1298
- <div id="method-M000118" class="method-detail">
1299
- <a name="M000118"></a>
1300
-
1301
- <div class="method-heading">
1302
- <a href="HTTP.src/M000118.html" target="Code" class="method-signature"
1303
- onclick="popupCode('HTTP.src/M000118.html');return false;">
1304
- <span class="method-name">read_timeout=</span><span class="method-args">(sec)</span>
1305
- </a>
1306
- </div>
1307
-
1308
- <div class="method-description">
1309
- <p>
1310
- Setter for the read_timeout attribute.
1311
- </p>
1312
- </div>
1313
- </div>
1314
-
1315
- <div id="method-M000153" class="method-detail">
1316
- <a name="M000153"></a>
1317
-
1318
- <div class="method-heading">
1319
- <a href="HTTP.src/M000153.html" target="Code" class="method-signature"
1320
- onclick="popupCode('HTTP.src/M000153.html');return false;">
1321
- <span class="method-name">request</span><span class="method-args">(req, body = nil) {|+response+| ...}</span>
1322
- </a>
1323
- </div>
1324
-
1325
- <div class="method-description">
1326
- <p>
1327
- Sends an <a href="HTTPRequest.html">HTTPRequest</a> object REQUEST to the
1328
- <a href="HTTP.html">HTTP</a> server. This method also sends DATA string if
1329
- REQUEST is a post/put request. Giving DATA for get/head request causes
1330
- ArgumentError.
1331
- </p>
1332
- <p>
1333
- When called with a block, yields an <a
1334
- href="HTTPResponse.html">HTTPResponse</a> object. The body of this response
1335
- will not have been read yet; the caller can process it using <a
1336
- href="HTTPResponse.html#M000166">HTTPResponse#read_body</a>, if desired.
1337
- </p>
1338
- <p>
1339
- Returns a <a href="HTTPResponse.html">HTTPResponse</a> object.
1340
- </p>
1341
- <p>
1342
- This method never raises Net::* exceptions.
1343
- </p>
1344
- </div>
1345
- </div>
1346
-
1347
- <div id="method-M000146" class="method-detail">
1348
- <a name="M000146"></a>
1349
-
1350
- <div class="method-heading">
1351
- <a href="HTTP.src/M000146.html" target="Code" class="method-signature"
1352
- onclick="popupCode('HTTP.src/M000146.html');return false;">
1353
- <span class="method-name">request_get</span><span class="method-args">(path, initheader = nil) {|+response+| ...}</span>
1354
- </a>
1355
- </div>
1356
-
1357
- <div class="method-description">
1358
- <p>
1359
- Sends a GET request to the <tt>path</tt> and gets a response, as an <a
1360
- href="HTTPResponse.html">HTTPResponse</a> object.
1361
- </p>
1362
- <p>
1363
- When called with a block, yields an <a
1364
- href="HTTPResponse.html">HTTPResponse</a> object. The body of this response
1365
- will not have been read yet; the caller can process it using <a
1366
- href="HTTPResponse.html#M000166">HTTPResponse#read_body</a>, if desired.
1367
- </p>
1368
- <p>
1369
- Returns the response.
1370
- </p>
1371
- <p>
1372
- This method never raises Net::* exceptions.
1373
- </p>
1374
- <pre>
1375
- response = http.request_get('/index.html')
1376
- # The entity body is already read here.
1377
- p response['content-type']
1378
- puts response.body
1379
-
1380
- # using block
1381
- http.request_get('/index.html') {|response|
1382
- p response['content-type']
1383
- response.read_body do |str| # read body now
1384
- print str
1385
- end
1386
- }
1387
- </pre>
1388
- </div>
1389
- </div>
1390
-
1391
- <div id="method-M000147" class="method-detail">
1392
- <a name="M000147"></a>
1393
-
1394
- <div class="method-heading">
1395
- <a href="HTTP.src/M000147.html" target="Code" class="method-signature"
1396
- onclick="popupCode('HTTP.src/M000147.html');return false;">
1397
- <span class="method-name">request_head</span><span class="method-args">(path, initheader = nil, &amp;block)</span>
1398
- </a>
1399
- </div>
1400
-
1401
- <div class="method-description">
1402
- <p>
1403
- Sends a HEAD request to the <tt>path</tt> and gets a response, as an <a
1404
- href="HTTPResponse.html">HTTPResponse</a> object.
1405
- </p>
1406
- <p>
1407
- Returns the response.
1408
- </p>
1409
- <p>
1410
- This method never raises Net::* exceptions.
1411
- </p>
1412
- <pre>
1413
- response = http.request_head('/index.html')
1414
- p response['content-type']
1415
- </pre>
1416
- </div>
1417
- </div>
1418
-
1419
- <div id="method-M000148" class="method-detail">
1420
- <a name="M000148"></a>
1421
-
1422
- <div class="method-heading">
1423
- <a href="HTTP.src/M000148.html" target="Code" class="method-signature"
1424
- onclick="popupCode('HTTP.src/M000148.html');return false;">
1425
- <span class="method-name">request_post</span><span class="method-args">(path, data, initheader = nil) {|+response+| ...}</span>
1426
- </a>
1427
- </div>
1428
-
1429
- <div class="method-description">
1430
- <p>
1431
- Sends a POST request to the <tt>path</tt> and gets a response, as an <a
1432
- href="HTTPResponse.html">HTTPResponse</a> object.
1433
- </p>
1434
- <p>
1435
- When called with a block, yields an <a
1436
- href="HTTPResponse.html">HTTPResponse</a> object. The body of this response
1437
- will not have been read yet; the caller can process it using <a
1438
- href="HTTPResponse.html#M000166">HTTPResponse#read_body</a>, if desired.
1439
- </p>
1440
- <p>
1441
- Returns the response.
1442
- </p>
1443
- <p>
1444
- This method never raises Net::* exceptions.
1445
- </p>
1446
- <pre>
1447
- # example
1448
- response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
1449
- p response.status
1450
- puts response.body # body is already read
1451
-
1452
- # using block
1453
- http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
1454
- p response.status
1455
- p response['content-type']
1456
- response.read_body do |str| # read body now
1457
- print str
1458
- end
1459
- }
1460
- </pre>
1461
- </div>
1462
- </div>
1463
-
1464
- <div id="method-M000152" class="method-detail">
1465
- <a name="M000152"></a>
1466
-
1467
- <div class="method-heading">
1468
- <a href="HTTP.src/M000152.html" target="Code" class="method-signature"
1469
- onclick="popupCode('HTTP.src/M000152.html');return false;">
1470
- <span class="method-name">send_request</span><span class="method-args">(name, path, data = nil, header = nil)</span>
1471
- </a>
1472
- </div>
1473
-
1474
- <div class="method-description">
1475
- <p>
1476
- Sends an <a href="HTTP.html">HTTP</a> request to the <a
1477
- href="HTTP.html">HTTP</a> server. This method also sends DATA string if
1478
- DATA is given.
1479
- </p>
1480
- <p>
1481
- Returns a <a href="HTTPResponse.html">HTTPResponse</a> object.
1482
- </p>
1483
- <p>
1484
- This method never raises Net::* exceptions.
1485
- </p>
1486
- <pre>
1487
- response = http.send_request('GET', '/index.html')
1488
- puts response.body
1489
- </pre>
1490
- </div>
1491
- </div>
1492
-
1493
- <div id="method-M000117" class="method-detail">
1494
- <a name="M000117"></a>
1495
-
1496
- <div class="method-heading">
1497
- <a href="HTTP.src/M000117.html" target="Code" class="method-signature"
1498
- onclick="popupCode('HTTP.src/M000117.html');return false;">
1499
- <span class="method-name">set_debug_output</span><span class="method-args">(output)</span>
1500
- </a>
1501
- </div>
1502
-
1503
- <div class="method-description">
1504
- <p>
1505
- <b>WARNING</b> This method causes serious security hole. Never use this
1506
- method in production code.
1507
- </p>
1508
- <p>
1509
- Set an output stream for debugging.
1510
- </p>
1511
- <pre>
1512
- http = Net::HTTP.new
1513
- http.set_debug_output $stderr
1514
- http.start { .... }
1515
- </pre>
1516
- </div>
1517
- </div>
1518
-
1519
- <div id="method-M000158" class="method-detail">
1520
- <a name="M000158"></a>
1521
-
1522
- <div class="method-heading">
1523
- <a href="HTTP.src/M000158.html" target="Code" class="method-signature"
1524
- onclick="popupCode('HTTP.src/M000158.html');return false;">
1525
- <span class="method-name">ssl_timeout</span><span class="method-args">()</span>
1526
- </a>
1527
- </div>
1528
-
1529
- <div class="method-description">
1530
- </div>
1531
- </div>
1532
-
1533
- <div id="method-M000159" class="method-detail">
1534
- <a name="M000159"></a>
1535
-
1536
- <div class="method-heading">
1537
- <a href="HTTP.src/M000159.html" target="Code" class="method-signature"
1538
- onclick="popupCode('HTTP.src/M000159.html');return false;">
1539
- <span class="method-name">ssl_timeout=</span><span class="method-args">(sec)</span>
1540
- </a>
1541
- </div>
1542
-
1543
- <div class="method-description">
1544
- </div>
1545
- </div>
1546
-
1547
- <div id="method-M000122" class="method-detail">
1548
- <a name="M000122"></a>
1549
-
1550
- <div class="method-heading">
1551
- <a href="HTTP.src/M000122.html" target="Code" class="method-signature"
1552
- onclick="popupCode('HTTP.src/M000122.html');return false;">
1553
- <span class="method-name">start</span><span class="method-args">( {|http| ...}</span>
1554
- </a>
1555
- </div>
1556
-
1557
- <div class="method-description">
1558
- <p>
1559
- Opens TCP connection and <a href="HTTP.html">HTTP</a> session.
1560
- </p>
1561
- <p>
1562
- When this method is called with block, gives a <a href="HTTP.html">HTTP</a>
1563
- object to the block and closes the TCP connection / <a
1564
- href="HTTP.html">HTTP</a> session after the block executed.
1565
- </p>
1566
- <p>
1567
- When called with a block, returns the return value of the block; otherwise,
1568
- returns self.
1569
- </p>
1570
- </div>
1571
- </div>
1572
-
1573
- <div id="method-M000119" class="method-detail">
1574
- <a name="M000119"></a>
1575
-
1576
- <div class="method-heading">
1577
- <a href="HTTP.src/M000119.html" target="Code" class="method-signature"
1578
- onclick="popupCode('HTTP.src/M000119.html');return false;">
1579
- <span class="method-name">started?</span><span class="method-args">()</span>
1580
- </a>
1581
- </div>
1582
-
1583
- <div class="method-description">
1584
- <p>
1585
- returns true if the <a href="HTTP.html">HTTP</a> session is started.
1586
- </p>
1587
- </div>
1588
- </div>
1589
-
1590
- <div id="method-M000160" class="method-detail">
1591
- <a name="M000160"></a>
1592
-
1593
- <div class="method-heading">
1594
- <span class="method-name">timeout=</span><span class="method-args">(sec)</span>
1595
- </div>
1596
-
1597
- <div class="method-description">
1598
- <p>
1599
- Alias for <a href="HTTP.html#M000159">ssl_timeout=</a>
1600
- </p>
1601
- </div>
1602
- </div>
1603
-
1604
- <div id="method-M000145" class="method-detail">
1605
- <a name="M000145"></a>
1606
-
1607
- <div class="method-heading">
1608
- <a href="HTTP.src/M000145.html" target="Code" class="method-signature"
1609
- onclick="popupCode('HTTP.src/M000145.html');return false;">
1610
- <span class="method-name">trace</span><span class="method-args">(path, initheader = nil)</span>
1611
- </a>
1612
- </div>
1613
-
1614
- <div class="method-description">
1615
- <p>
1616
- Sends a TRACE request to the <tt>path</tt> and gets a response, as an <a
1617
- href="HTTPResponse.html">HTTPResponse</a> object.
1618
- </p>
1619
- </div>
1620
- </div>
1621
-
1622
- <div id="method-M000138" class="method-detail">
1623
- <a name="M000138"></a>
1624
-
1625
- <div class="method-heading">
1626
- <a href="HTTP.src/M000138.html" target="Code" class="method-signature"
1627
- onclick="popupCode('HTTP.src/M000138.html');return false;">
1628
- <span class="method-name">unlock</span><span class="method-args">(path, body, initheader = nil)</span>
1629
- </a>
1630
- </div>
1631
-
1632
- <div class="method-description">
1633
- <p>
1634
- Sends a UNLOCK request to the <tt>path</tt> and gets a response, as an <a
1635
- href="HTTPResponse.html">HTTPResponse</a> object.
1636
- </p>
1637
- </div>
1638
- </div>
1639
-
1640
- <div id="method-M000155" class="method-detail">
1641
- <a name="M000155"></a>
1642
-
1643
- <div class="method-heading">
1644
- <span class="method-name">use_ssl</span><span class="method-args">()</span>
1645
- </div>
1646
-
1647
- <div class="method-description">
1648
- <p>
1649
- Alias for <a href="HTTP.html#M000121">use_ssl?</a>
1650
- </p>
1651
- </div>
1652
- </div>
1653
-
1654
- <div id="method-M000156" class="method-detail">
1655
- <a name="M000156"></a>
1656
-
1657
- <div class="method-heading">
1658
- <a href="HTTP.src/M000156.html" target="Code" class="method-signature"
1659
- onclick="popupCode('HTTP.src/M000156.html');return false;">
1660
- <span class="method-name">use_ssl=</span><span class="method-args">(flag)</span>
1661
- </a>
1662
- </div>
1663
-
1664
- <div class="method-description">
1665
- <p>
1666
- Turn on/off SSL. This flag must be set before starting session. If you
1667
- change <a href="HTTP.html#M000155">use_ssl</a> value after session started,
1668
- a <a href="HTTP.html">Net::HTTP</a> object raises IOError.
1669
- </p>
1670
- </div>
1671
- </div>
1672
-
1673
- <div id="method-M000154" class="method-detail">
1674
- <a name="M000154"></a>
1675
-
1676
- <div class="method-heading">
1677
- <a href="HTTP.src/M000154.html" target="Code" class="method-signature"
1678
- onclick="popupCode('HTTP.src/M000154.html');return false;">
1679
- <span class="method-name">use_ssl?</span><span class="method-args">()</span>
1680
- </a>
1681
- </div>
1682
-
1683
- <div class="method-description">
1684
- </div>
1685
- </div>
1686
-
1687
- <div id="method-M000121" class="method-detail">
1688
- <a name="M000121"></a>
1689
-
1690
- <div class="method-heading">
1691
- <a href="HTTP.src/M000121.html" target="Code" class="method-signature"
1692
- onclick="popupCode('HTTP.src/M000121.html');return false;">
1693
- <span class="method-name">use_ssl?</span><span class="method-args">()</span>
1694
- </a>
1695
- </div>
1696
-
1697
- <div class="method-description">
1698
- <p>
1699
- returns true if use SSL/TLS with <a href="HTTP.html">HTTP</a>.
1700
- </p>
1701
- </div>
1702
- </div>
1703
-
1704
-
1705
- </div>
1706
-
1707
-
1708
- </div>
1709
-
1710
-
1711
- <div id="validator-badges">
1712
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1713
- </div>
1714
-
1715
- </body>
1716
- </html>