http2 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/http2.gemspec +1 -1
- data/lib/http2.rb +13 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
data/http2.gemspec
CHANGED
data/lib/http2.rb
CHANGED
@@ -242,7 +242,11 @@ class Http2
|
|
242
242
|
end
|
243
243
|
|
244
244
|
def delete(args)
|
245
|
-
|
245
|
+
if args[:json]
|
246
|
+
return self.post(args.merge(:method => :delete))
|
247
|
+
else
|
248
|
+
return self.get(args.merge(:method => :delete))
|
249
|
+
end
|
246
250
|
end
|
247
251
|
|
248
252
|
#Tries to write a string to the socket. If it fails it reconnects and tries again.
|
@@ -348,7 +352,7 @@ class Http2
|
|
348
352
|
return praw
|
349
353
|
end
|
350
354
|
|
351
|
-
VALID_ARGUMENTS_POST = [:post, :url, :headers, :json]
|
355
|
+
VALID_ARGUMENTS_POST = [:post, :url, :headers, :json, :method]
|
352
356
|
#Posts to a certain page.
|
353
357
|
#===Examples
|
354
358
|
# res = http.post("login.php", {"username" => "John Doe", "password" => 123)
|
@@ -360,6 +364,12 @@ class Http2
|
|
360
364
|
args = self.parse_args(args)
|
361
365
|
content_type = "application/x-www-form-urlencoded"
|
362
366
|
|
367
|
+
if args.key?(:method) && args[:method]
|
368
|
+
method = args[:method].to_s.upcase
|
369
|
+
else
|
370
|
+
method = "POST"
|
371
|
+
end
|
372
|
+
|
363
373
|
if args[:json]
|
364
374
|
require "json" unless ::Kernel.const_defined?(:JSON)
|
365
375
|
praw = JSON.generate(args[:json])
|
@@ -375,7 +385,7 @@ class Http2
|
|
375
385
|
@mutex.synchronize do
|
376
386
|
puts "Doing post." if @debug
|
377
387
|
|
378
|
-
header_str = "
|
388
|
+
header_str = "#{method} /#{args[:url]} HTTP/1.1#{@nl}"
|
379
389
|
header_str << self.header_str({"Content-Length" => praw.length, "Content-Type" => content_type}.merge(self.default_headers(args)), args)
|
380
390
|
header_str << @nl
|
381
391
|
header_str << praw
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
segments:
|
115
115
|
- 0
|
116
|
-
hash:
|
116
|
+
hash: 1149026515699745004
|
117
117
|
version: '0'
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|