rufus-jig 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +5 -0
- data/lib/rufus/jig/http.rb +16 -18
- data/lib/rufus/jig.rb +1 -1
- metadata +1 -1
data/CHANGELOG.txt
CHANGED
data/lib/rufus/jig/http.rb
CHANGED
@@ -289,50 +289,48 @@ if defined?(Patron) # gem install patron
|
|
289
289
|
def initialize (host, port, opts={})
|
290
290
|
|
291
291
|
super(host, port, opts)
|
292
|
-
|
293
|
-
refresh
|
294
292
|
end
|
295
293
|
|
296
|
-
|
294
|
+
protected
|
295
|
+
|
296
|
+
# One patron session per thread
|
297
297
|
#
|
298
|
-
def
|
298
|
+
def get_patron
|
299
299
|
|
300
|
-
|
301
|
-
@patron.base_url = "#{@host}:#{@port}"
|
300
|
+
patron = Thread.current["#{self.class}_patron"]
|
302
301
|
|
303
|
-
|
304
|
-
@options[:user_agent] || "#{self.class} #{Rufus::Jig::VERSION} (patron)"
|
305
|
-
end
|
302
|
+
return patron if patron
|
306
303
|
|
307
|
-
|
308
|
-
|
309
|
-
def request (method, path, data, opts={})
|
304
|
+
patron = Patron::Session.new
|
305
|
+
patron.base_url = "#{@host}:#{@port}"
|
310
306
|
|
311
|
-
|
307
|
+
patron.headers['User-Agent'] =
|
308
|
+
@options[:user_agent] ||
|
309
|
+
"#{self.class} #{Rufus::Jig::VERSION} #{Thread.current.object_id} (patron)"
|
312
310
|
|
313
|
-
|
311
|
+
Thread.current["#{self.class}_patron"] = patron
|
314
312
|
end
|
315
313
|
|
316
314
|
def do_get (path, data, opts)
|
317
315
|
|
318
|
-
|
316
|
+
get_patron.get(path, opts)
|
319
317
|
end
|
320
318
|
|
321
319
|
def do_post (path, data, opts)
|
322
320
|
|
323
|
-
|
321
|
+
get_patron.post(path, data, opts)
|
324
322
|
end
|
325
323
|
|
326
324
|
def do_put (path, data, opts)
|
327
325
|
|
328
326
|
opts['Expect'] = '' unless @options[:expect]
|
329
327
|
|
330
|
-
|
328
|
+
get_patron.put(path, data, opts)
|
331
329
|
end
|
332
330
|
|
333
331
|
def do_delete (path, data, opts)
|
334
332
|
|
335
|
-
|
333
|
+
get_patron.delete(path, opts)
|
336
334
|
end
|
337
335
|
end
|
338
336
|
|
data/lib/rufus/jig.rb
CHANGED