typhoeus 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
data/lib/typhoeus.rb CHANGED
@@ -14,7 +14,7 @@ require 'typhoeus/request'
14
14
  require 'typhoeus/hydra'
15
15
 
16
16
  module Typhoeus
17
- VERSION = "0.1.20"
17
+ VERSION = "0.1.21"
18
18
 
19
19
  def self.easy_object_pool
20
20
  @easy_objects ||= []
data/lib/typhoeus/easy.rb CHANGED
@@ -22,7 +22,8 @@ module Typhoeus
22
22
  :CURLOPT_USERPWD => 10000 + 5,
23
23
  :CURLOPT_VERBOSE => 41,
24
24
  :CURLOPT_PROXY => 10004,
25
- :CURLOPT_VERIFYPEER => 64
25
+ :CURLOPT_VERIFYPEER => 64,
26
+ :CURLOPT_NOBODY => 44
26
27
  }
27
28
  INFO_VALUES = {
28
29
  :CURLINFO_RESPONSE_CODE => 2097154,
@@ -128,6 +129,8 @@ module Typhoeus
128
129
  elsif method == :put
129
130
  set_option(OPTION_VALUES[:CURLOPT_UPLOAD], 1)
130
131
  self.request_body = "" unless @request_body
132
+ elsif method == :head
133
+ set_option(OPTION_VALUES[:CURLOPT_NOBODY], 1)
131
134
  else
132
135
  set_option(OPTION_VALUES[:CURLOPT_CUSTOMREQUEST], "DELETE")
133
136
  end
@@ -116,5 +116,9 @@ module Typhoeus
116
116
  def self.delete(url, params = {})
117
117
  run(url, params.merge(:method => :delete))
118
118
  end
119
+
120
+ def self.head(url, params = {})
121
+ run(url, params.merge(:method => :head))
122
+ end
119
123
  end
120
124
  end
data/spec/servers/app.rb CHANGED
@@ -53,6 +53,10 @@ get '/**' do
53
53
  request.env.merge!(:body => request.body.read).to_json
54
54
  end
55
55
 
56
+ head '/**' do
57
+ sleep params["delay"].to_i if params.has_key?("delay")
58
+ end
59
+
56
60
  put '/**' do
57
61
  puts request.inspect
58
62
  request.env.merge!(:body => request.body.read).to_json
@@ -101,6 +101,16 @@ describe Typhoeus::Easy do
101
101
  end
102
102
  end
103
103
 
104
+ describe "head" do
105
+ it "should perform a head" do
106
+ easy = Typhoeus::Easy.new
107
+ easy.url = "http://localhost:3002"
108
+ easy.method = :head
109
+ easy.perform
110
+ easy.response_code.should == 200
111
+ end
112
+ end
113
+
104
114
  describe "start_time" do
105
115
  it "should be get/settable" do
106
116
  time = Time.now
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix