http2 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/http2.gemspec +1 -1
  3. data/lib/http2.rb +13 -3
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "http2"
8
- s.version = "0.0.15"
8
+ s.version = "0.0.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
@@ -242,7 +242,11 @@ class Http2
242
242
  end
243
243
 
244
244
  def delete(args)
245
- return self.get(args.merge(:method => :delete))
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 = "POST /#{args[:url]} HTTP/1.1#{@nl}"
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.15
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: -3116192511012734724
116
+ hash: 1149026515699745004
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  none: false