http2 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/shippable.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - CODECLIMATE_REPO_TOKEN=df980a87f4dbf846f13115f0ff1a8179bf165b645dcf12204a96c91d9e665f8e bundle exec rspec
6
+ notifications:
7
+ email: false
data/spec/http2_spec.rb CHANGED
@@ -6,12 +6,12 @@ describe "Http2" do
6
6
  "test1" => "test2"
7
7
  )
8
8
  raise "Expected 'test1=test2' but got: '#{res}'." if res != "test1=test2"
9
-
9
+
10
10
  res = Http2.post_convert_data(
11
11
  "test1" => [1, 2, 3]
12
12
  )
13
13
  raise "Expected 'test1%5B0%5D=1&test1%5B1%5D=2&test1%5B2%5D=3' but got: '#{res}'." if res != "test1%5B0%5D=1&test1%5B1%5D=2&test1%5B2%5D=3"
14
-
14
+
15
15
  res = Http2.post_convert_data(
16
16
  "test1" => {
17
17
  "order" => {
@@ -21,15 +21,15 @@ describe "Http2" do
21
21
  )
22
22
  raise "Expected 'test1%5Border%5D%5B%5B%3ABnet_profile%2C+%22profile_id%22%5D%5D=5' but got: '#{res}'." if res != "test1%5Border%5D%5B%5B%3ABnet_profile%2C+%22profile_id%22%5D%5D=5"
23
23
  end
24
-
24
+
25
25
  it "should be able to do normal post-requests." do
26
26
  require "json"
27
-
27
+
28
28
  #Test posting keep-alive and advanced post-data.
29
29
  Http2.new(:host => "www.partyworm.dk", :debug => false) do |http|
30
30
  0.upto(5) do
31
31
  resp = http.get("multipart_test.php")
32
-
32
+
33
33
  resp = http.post(:url => "multipart_test.php?choice=post-test", :post => {
34
34
  "val1" => "test1",
35
35
  "val2" => "test2",
@@ -49,7 +49,7 @@ describe "Http2" do
49
49
  "val9" => ["a", "b", "d"]
50
50
  })
51
51
  res = JSON.parse(resp.body)
52
-
52
+
53
53
  raise "Expected 'res' to be a hash." if !res.is_a?(Hash)
54
54
  raise "Error 1" if res["val1"] != "test1"
55
55
  raise "Error 2" if res["val2"] != "test2"
@@ -60,13 +60,13 @@ describe "Http2" do
60
60
  end
61
61
  end
62
62
  end
63
-
63
+
64
64
  it "should be able to do multipart-requests and keep-alive when using multipart." do
65
65
  Http2.new(:host => "www.partyworm.dk", :follow_redirects => false, :encoding_gzip => false, :debug => false) do |http|
66
66
  0.upto(5) do
67
67
  fpath = File.realpath(__FILE__)
68
68
  fpath2 = "#{File.realpath(File.dirname(__FILE__))}/../lib/http2.rb"
69
-
69
+
70
70
  resp = http.post_multipart(:url => "multipart_test.php", :post => {
71
71
  "test_var" => "true",
72
72
  "test_file1" => {
@@ -78,16 +78,16 @@ describe "Http2" do
78
78
  :filename => "http2.rb"
79
79
  }
80
80
  })
81
-
81
+
82
82
  data = JSON.parse(resp.body)
83
-
83
+
84
84
  raise "Expected 'test_var' post to be 'true' but it wasnt: '#{data["post"]["test_var"]}'." if data["post"]["test_var"] != "true"
85
85
  raise "Expected 'test_file1' to be the same as file but it wasnt:\n#{data["files_data"]["test_file1"]}\n\n#{File.read(fpath)}" if data["files_data"]["test_file1"] != File.read(fpath)
86
86
  raise "Expected 'test_file2' to be the same as file but it wasnt:\n#{data["files_data"]["test_file2"]}\n\n#{File.read(fpath)}" if data["files_data"]["test_file2"] != File.read(fpath2)
87
87
  end
88
88
  end
89
89
  end
90
-
90
+
91
91
  it "it should be able to handle keep-alive correctly" do
92
92
  urls = [
93
93
  "?show=users_search",
@@ -96,7 +96,7 @@ describe "Http2" do
96
96
  "?show=forum&fid=9&tid=1917&page=0"
97
97
  ]
98
98
  urls = ["robots.txt"]
99
-
99
+
100
100
  Http2.new(:host => "www.partyworm.dk", :debug => false) do |http|
101
101
  0.upto(105) do |count|
102
102
  url = urls[rand(urls.size)]
@@ -106,43 +106,43 @@ describe "Http2" do
106
106
  end
107
107
  end
108
108
  end
109
-
109
+
110
110
  it "should be able to convert URL's to 'is.gd'-short-urls" do
111
111
  isgd = Http2.isgdlink("https://github.com/kaspernj/http2")
112
112
  raise "Expected isgd-var to be valid but it wasnt: '#{isgd}'." if !isgd.match(/^http:\/\/is\.gd\/([A-z\d]+)$/)
113
113
  end
114
-
114
+
115
115
  it "should raise exception when something is not found" do
116
116
  expect{
117
117
  Http2.new(:host => "www.partyworm.dk") do |http|
118
118
  http.get("something_that_does_not_exist.php")
119
119
  end
120
- }.to raise_error
120
+ }.to raise_error(::Http2::Errors::Notfound)
121
121
  end
122
-
122
+
123
123
  it "should be able to post json" do
124
124
  Http2.new(:host => "http2test.kaspernj.org") do |http|
125
125
  res = http.post(
126
126
  :url => "/jsontest.php",
127
127
  :json => {:testkey => "testvalue"}
128
128
  )
129
-
129
+
130
130
  data = JSON.parse(res.body)
131
131
  data["_SERVER"]["CONTENT_TYPE"].should eql("application/json")
132
132
  data["PHP_JSON_INPUT"]["testkey"].should eql("testvalue")
133
133
  end
134
134
  end
135
-
135
+
136
136
  it "should be able to post custom content types" do
137
137
  require "json"
138
-
138
+
139
139
  Http2.new(:host => "http2test.kaspernj.org") do |http|
140
140
  res = http.post(
141
141
  :url => "/content_type_test.php",
142
142
  :content_type => "plain/text",
143
143
  :post => "test1_test2_test3"
144
144
  )
145
-
145
+
146
146
  data = JSON.parse(res.body)
147
147
  data["_SERVER"]["CONTENT_TYPE"].should eql("plain/text")
148
148
  data["PHP_INPUT"].should eql("test1_test2_test3")
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
6
  require 'rspec'
@@ -8,5 +11,5 @@ require 'http2'
8
11
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
12
 
10
13
  RSpec.configure do |config|
11
-
14
+
12
15
  end
metadata CHANGED
@@ -1,78 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http2
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.23
4
+ version: 0.0.24
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kasper Johansen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
14
+ name: string-cases
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
15
22
  version_requirements: !ruby/object:Gem::Requirement
16
- none: false
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
17
30
  requirements:
18
31
  - - ~>
19
32
  - !ruby/object:Gem::Version
20
33
  version: 2.8.0
21
- name: rspec
22
34
  type: :development
23
35
  prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
25
- none: false
36
+ version_requirements: !ruby/object:Gem::Requirement
26
37
  requirements:
27
38
  - - ~>
28
39
  - !ruby/object:Gem::Version
29
40
  version: 2.8.0
30
41
  - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
32
- none: false
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
33
44
  requirements:
34
45
  - - ~>
35
46
  - !ruby/object:Gem::Version
36
47
  version: '3.12'
37
- name: rdoc
38
48
  type: :development
39
49
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
41
- none: false
50
+ version_requirements: !ruby/object:Gem::Requirement
42
51
  requirements:
43
52
  - - ~>
44
53
  - !ruby/object:Gem::Version
45
54
  version: '3.12'
46
55
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
48
- none: false
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
49
58
  requirements:
50
- - - ! '>='
59
+ - - '>='
51
60
  - !ruby/object:Gem::Version
52
61
  version: 1.0.0
53
- name: bundler
54
62
  type: :development
55
63
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
57
- none: false
64
+ version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
- - - ! '>='
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: 1.0.0
62
69
  - !ruby/object:Gem::Dependency
63
- version_requirements: !ruby/object:Gem::Requirement
64
- none: false
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
65
72
  requirements:
66
- - - ~>
73
+ - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: 1.8.4
69
- name: jeweler
70
76
  type: :development
71
77
  prerelease: false
72
- requirement: !ruby/object:Gem::Requirement
73
- none: false
78
+ version_requirements: !ruby/object:Gem::Requirement
74
79
  requirements:
75
- - - ~>
80
+ - - '>='
76
81
  - !ruby/object:Gem::Version
77
82
  version: 1.8.4
78
83
  description: A lightweight framework for doing http-connections in Ruby. Supports
@@ -82,50 +87,49 @@ executables: []
82
87
  extensions: []
83
88
  extra_rdoc_files:
84
89
  - LICENSE.txt
85
- - README.rdoc
90
+ - README.md
86
91
  files:
87
92
  - .document
88
93
  - .rspec
89
94
  - Gemfile
90
95
  - Gemfile.lock
91
96
  - LICENSE.txt
92
- - README.rdoc
97
+ - README.md
93
98
  - Rakefile
94
99
  - VERSION
95
100
  - http2.gemspec
96
101
  - include/errors.rb
102
+ - include/post_multipart_helper.rb
97
103
  - include/response.rb
104
+ - include/response_reader.rb
98
105
  - include/utils.rb
99
106
  - lib/http2.rb
107
+ - shippable.yml
100
108
  - spec/http2_spec.rb
101
109
  - spec/spec_helper.rb
102
110
  homepage: http://github.com/kaspernj/http2
103
111
  licenses:
104
112
  - MIT
113
+ metadata: {}
105
114
  post_install_message:
106
115
  rdoc_options: []
107
116
  require_paths:
108
117
  - lib
109
118
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
119
  requirements:
112
- - - ! '>='
120
+ - - '>='
113
121
  - !ruby/object:Gem::Version
114
- segments:
115
- - 0
116
- hash: -1592181993674694658
117
122
  version: '0'
118
123
  required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
124
  requirements:
121
- - - ! '>='
125
+ - - '>='
122
126
  - !ruby/object:Gem::Version
123
127
  version: '0'
124
128
  requirements: []
125
129
  rubyforge_project:
126
- rubygems_version: 1.8.23
130
+ rubygems_version: 2.0.14
127
131
  signing_key:
128
- specification_version: 3
132
+ specification_version: 4
129
133
  summary: A lightweight framework for doing http-connections in Ruby. Supports cookies,
130
134
  keep-alive, compressing and much more.
131
135
  test_files: []
data/README.rdoc DELETED
@@ -1,45 +0,0 @@
1
- = http2
2
-
3
- Example of usage:
4
-
5
- require "rubygems"
6
- require "http2"
7
-
8
- Http2.new(:host => "www.google.dk") do |http|
9
- #Get-request.
10
- res = http.get("path/to/something")
11
- puts res.body
12
- puts "All response-headers: #{res.headers}"
13
- puts "Specific header: #{res.header("HeaderName")}"
14
-
15
- #Post-request.
16
- res = http.post(:url => "path/to/something", :post => {
17
- "some_post_val" => "some_value"
18
- })
19
-
20
- #Post-multipart (upload).
21
- res = http.post_multipart(:url => "path/to/something", :post => {
22
- "test_file1" => {
23
- :fpath => fpath,
24
- :filename => "specfile"
25
- }
26
- })
27
-
28
- puts "Cookies until now: #{http.cookies}"
29
- end
30
-
31
- == Contributing to http2
32
-
33
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
34
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
35
- * Fork the project.
36
- * Start a feature/bugfix branch.
37
- * Commit and push until you are happy with your contribution.
38
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
39
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
40
-
41
- == Copyright
42
-
43
- Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
44
- further details.
45
-