-
Notifications
You must be signed in to change notification settings - Fork 229
/
index.html
211 lines (185 loc) · 5.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>taf2/curb @ GitHub</title>
<style type="text/css">
body {
margin-top: 1.0em;
background-color: #fff;
font-family: "helvetica";
color: #000;
}
#container {
margin: 0 auto;
width: 700px;
}
h1 { font-size: 3.8em; color: #de7a5b; margin-bottom: 3px; }
h1 .small { font-size: 0.4em; }
h1 a { text-decoration: none }
h2 { font-size: 1.5em; color: #de7a5b; }
h3 { text-align: center; color: #de7a5b; }
a { color: #de7a5b; }
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
.description cite { font-size: 90%; display:block; margin-top:10px; }
.download { float: right; }
pre { background: #000; color: #fff; padding: 15px;}
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
.footer { text-align:center; padding-top:30px; font-style: italic; }
</style>
</head>
<body>
<a href="http://github.com/taf2/curb"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<div class="download">
<a href="http://github.com/taf2/curb/zipball/master">
<img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a>
<a href="http://github.com/taf2/curb/tarball/master">
<img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a>
</div>
<h1><a href="http://github.com/taf2/curb">curb</a>
<span class="small">by <a href="http://github.com/taf2">taf2</a></span></h1>
<div class="description">
Curb (probably CUrl-RuBy or something) provides <a href="http://ruby-lang.org/">Ruby-language</a> bindings for
<a title="A fully-featured client-side URL transfer library cURL and libcurl." href="http://curl.haxx.se/">libcurl(3)</a>.
<cite>Curb supports libcurl's 'easy' and 'multi' modes.</cite>
</div>
<h2>Dependencies</h2>
<p><a href="http://curl.haxx.se/">libcurl</a></p>
<h2>Examples</h2>
<h3>Simple fetch via HTTP:</h3>
<pre>
c = Curl::Easy.perform("http://www.google.co.uk")
puts c.body_str
</pre>
<h3>Same thing, more manual</h3>
<pre>
c = Curl::Easy.new("http://www.google.co.uk")
c.perform
puts c.body_str
</pre>
<h3>Additional config</h3>
<pre>
Curl::Easy.perform("http://www.google.co.uk") do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.verbose = true
end
</pre>
<h3>Same thing, more manual</h3>
<pre>
c = Curl::Easy.new("http://www.google.co.uk") do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.verbose = true
end
c.perform
</pre>
<h3>Supplying custom handlers</h3>
<pre>
c = Curl::Easy.new("http://www.google.co.uk")
c.on_body { |data| print(data) }
c.on_header { |data| print(data) }
c.perform
</pre>
<h3>Reusing Curls</h3>
<pre>
c = Curl::Easy.new
["http://www.google.co.uk", "http://www.ruby-lang.org/"].map do |url|
c.url = url
c.perform
c.body_str
end
</pre>
<h3>HTTP POST form</h3>
<pre>
c = Curl::Easy.http_post("http://my.rails.box/thing/create",
Curl::PostField.content('thing[name]', 'box',
Curl::PostField.content('thing[type]', 'storage')
</pre>
<h3>HTTP POST file upload</h3>
<pre>
c = Curl::Easy.new("http://my.rails.box/files/upload")
c.multipart_form_post = true
c.http_post(Curl::PostField.file('myfile.rb'))
</pre>
<h3>Multi Interface (Basic)</h3>
<h4>make multiple GET requests</h4>
<pre>
easy_options = {:follow_location => true}
multi_options = {:pipeline => true}
Curl::Multi.get('url1','url2','url3','url4','url5', easy_options, multi_options) do|easy|
# do something interesting with the easy response
puts easy.last_effective_url
end
</pre>
<h4>make multiple POST requests</h4>
<pre>
easy_options = {:follow_location => true, :multipart_form_post => true}
multi_options = {:pipeline => true}
url_fields = [
{ :url => 'url1', :post_fields => {'f1' => 'v1'} },
{ :url => 'url2', :post_fields => {'f1' => 'v1'} },
{ :url => 'url3', :post_fields => {'f1' => 'v1'} }
]
Curl::Multi.post(url_fields, easy_options, multi_options) do|easy|
# do something interesting with the easy response
puts easy.last_effective_url
end
</pre>
<h3>Multi Interface (Advanced)</h3>
<pre>
responses = {}
requests = ["http://www.google.co.uk/", "http://www.ruby-lang.org/"]
m = Curl::Multi.new
# add a few easy handles
requests.each do |url|
responses[url] = ""
c = Curl::Easy.new(url) do|curl|
curl.follow_location = true
curl.on_body{|data| responses[url] << data; data.size }
end
m.add(c)
end
m.perform do
puts "idling... can do some work here, including add new requests"
end
requests.each do|url|
puts responses[url]
end
</pre>
<h2>Install</h2>
<p>gem install taf2-curb</p>
<h2>Authors</h2>
<ul>
<li>Ross Bamford</li>
<li>Todd A. Fisher</li>
</ul>
<h2>Contributors</h2>
<ul>
<li>brycethornton</li>
<li>Cheah Chu Yeow</li>
<li>mobileAgent</li>
<li>Ian MacLeod</li>
<li>Ilya Grigorik</li>
<li>Jeff Whitmire</li>
<li>Matthew Beale</li>
<li>Phi.Sanders</li>
<li>Phillip Toland</li>
</ul>
<h2>Contact</h2>
<p>taf2 via github.com</p>
<h2>Download</h2>
<p>
You can download this project in either
<a href="http://github.com/taf2/curb/zipball/master">zip</a> or
<a href="http://github.com/taf2/curb/tarball/master">tar</a> formats.
</p>
<p>You can also clone the project with <a href="http://git-scm.com">Git</a>
by running:
<pre>$ git clone git://github.com/taf2/curb</pre>
</p>
<div class="footer">
get the source code on GitHub : <a href="http://github.com/taf2/curb">taf2/curb</a>
</div>
</div>
</body>
</html>