righttp 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rig/http.rb +7 -8
- data/righttp.gemspec +1 -1
- data/test/test_http.rb +16 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/rig/http.rb
CHANGED
@@ -28,7 +28,7 @@ module Rig
|
|
28
28
|
def send
|
29
29
|
begin
|
30
30
|
tcp_socket = TCPSocket.new( @options[:host], @options[:port] )
|
31
|
-
tcp_socket.write( @header.to_s
|
31
|
+
tcp_socket.write( @header.to_s + @body.to_s )
|
32
32
|
response = tcp_socket.read
|
33
33
|
rescue => exception
|
34
34
|
puts exception.message
|
@@ -69,13 +69,12 @@ module Rig
|
|
69
69
|
}
|
70
70
|
uri_options.merge( options.last )
|
71
71
|
when :advanced
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
72
|
+
options.first[:http_method] ||= "GET"
|
73
|
+
options.first[:host]
|
74
|
+
options.first[:port] ||= 80
|
75
|
+
options.first[:path] ||= "/"
|
76
|
+
options.first[:query]
|
77
|
+
options.first
|
79
78
|
else
|
80
79
|
raise ArgumentError
|
81
80
|
end
|
data/righttp.gemspec
CHANGED
data/test/test_http.rb
CHANGED
@@ -77,7 +77,6 @@ class TestHttp < Test::Unit::TestCase
|
|
77
77
|
:port=>80,
|
78
78
|
:path=>"/",
|
79
79
|
:http_method=>"GET",
|
80
|
-
:query => nil,
|
81
80
|
:content_type=>"text/plain",
|
82
81
|
:content_length=>0
|
83
82
|
}
|
@@ -208,6 +207,22 @@ class TestHttp < Test::Unit::TestCase
|
|
208
207
|
assert_equal 200, response.status
|
209
208
|
end
|
210
209
|
|
210
|
+
test "more advanced post request" do
|
211
|
+
request = Rig::HTTP.new(
|
212
|
+
:host => "beta.hoccer.com",
|
213
|
+
:path => "/events",
|
214
|
+
:http_method => "POST",
|
215
|
+
:body => {
|
216
|
+
"event[type]" => "Drop",
|
217
|
+
"event[latitude]" => "latitude",
|
218
|
+
"event[longitude]" => "longitude",
|
219
|
+
"event[location_accuracy]" => 100,
|
220
|
+
"event[lifetime]" => 600
|
221
|
+
}
|
222
|
+
)
|
223
|
+
assert_equal false, request.body.multipart?
|
224
|
+
end
|
225
|
+
|
211
226
|
#test "multipart body gets properly created" do
|
212
227
|
# post = HTTP.new(
|
213
228
|
# :host => "localhost",
|