http2 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +82 -29
- data/Rakefile +2 -14
- data/include/connection.rb +2 -2
- data/include/post_request.rb +13 -2
- data/include/response.rb +24 -1
- data/include/response_reader.rb +1 -1
- data/include/url_builder.rb +1 -1
- data/lib/http2.rb +1 -1
- data/spec/helpers.rb +29 -0
- data/spec/http2/response_spec.rb +4 -4
- data/spec/http2_spec.rb +44 -40
- data/spec/spec_helper.rb +3 -0
- data/spec/spec_root/content_type_test.rhtml +4 -0
- data/spec/spec_root/json_test.rhtml +9 -0
- data/spec/spec_root/multipart_test.rhtml +28 -0
- data/spec/spec_root/redirect_test.rhtml +3 -0
- metadata +63 -13
- data/.document +0 -5
- data/.rspec +0 -1
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -77
- data/VERSION +0 -1
- data/http2.gemspec +0 -78
- data/shippable.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a58ef37e262df0923fbbcabfbb596dda05eb4c
|
4
|
+
data.tar.gz: 4d9b2368eeb6a303ea63e392f15883429ffc0ab7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e39cd726b145f5143567b7a54f0b8e79f77668a7ac8011351e817b99b4487783a91197b7440cb2ad1a3659268f8259eb5da73c5996e2d4ce2c110853aa035fbe
|
7
|
+
data.tar.gz: 971fd5c395b68e5e4c0d83bf57d6a8c5a6abb7f63afaaf8a8246ebd65070f7144df7739759989c8ae56b60011965fdb43ba6ce1c67215bc1dc483243a0d927e9
|
data/README.md
CHANGED
@@ -1,49 +1,95 @@
|
|
1
|
-
# http2
|
2
|
-
|
3
1
|
[![Build Status](https://api.shippable.com/projects/53bd3eef2e23bdcb03c0df9e/badge/master)](https://www.shippable.com/projects/53bd3eef2e23bdcb03c0df9e)
|
4
2
|
[![Code Climate](https://codeclimate.com/github/kaspernj/http2.png)](https://codeclimate.com/github/kaspernj/http2)
|
5
3
|
[![Code Climate](https://codeclimate.com/github/kaspernj/http2/coverage.png)](https://codeclimate.com/github/kaspernj/http2)
|
6
4
|
|
7
|
-
|
5
|
+
# http2
|
6
|
+
|
7
|
+
A HTTP-framework for Ruby supporting keep-alive, compression, JSON-posting, detailed inspection of responses and much more.
|
8
|
+
|
9
|
+
# Usage
|
8
10
|
|
9
11
|
```ruby
|
10
12
|
require "rubygems"
|
11
13
|
require "http2"
|
12
14
|
|
13
15
|
Http2.new(host: "www.google.dk") do |http|
|
14
|
-
#
|
15
|
-
res = http.get("path/to/something")
|
16
|
-
puts res.body
|
17
|
-
puts "All response-headers: #{res.headers}"
|
18
|
-
puts "Specific header: #{res.header("HeaderName")}"
|
19
|
-
|
20
|
-
#Post-request.
|
21
|
-
res = http.post(url: "path/to/something", post: {
|
22
|
-
"some_post_val" => "some_value"
|
23
|
-
})
|
24
|
-
|
25
|
-
res.content_type #=> "text/html"
|
26
|
-
|
27
|
-
#Post-multipart (upload).
|
28
|
-
res = http.post_multipart(url: "path/to/something", post: {
|
29
|
-
"test_file1" => {
|
30
|
-
fpath: fpath,
|
31
|
-
filename: "specfile"
|
32
|
-
}
|
33
|
-
})
|
34
|
-
|
35
|
-
puts "Cookies until now: #{http.cookies}"
|
16
|
+
# Do requests here.
|
36
17
|
end
|
37
18
|
```
|
38
19
|
|
39
|
-
|
20
|
+
Or without using a block for ensuring closing of connection:
|
21
|
+
```ruby
|
22
|
+
http = Http2.new(...)
|
23
|
+
|
24
|
+
# Do requests here.
|
25
|
+
|
26
|
+
http.close
|
27
|
+
```
|
28
|
+
|
29
|
+
## Get requests
|
30
|
+
```ruby
|
31
|
+
res = http.get("path/to/something")
|
32
|
+
```
|
33
|
+
|
34
|
+
## Post requests
|
35
|
+
```ruby
|
36
|
+
res = http.post(url: "path/to/something", post: {
|
37
|
+
"some_post_val" => "some_value"
|
38
|
+
})
|
39
|
+
```
|
40
|
+
|
41
|
+
### Extra headers
|
42
|
+
```ruby
|
43
|
+
res = http.post(
|
44
|
+
url: "path",
|
45
|
+
headers: {"Auth": "123"},
|
46
|
+
post: {data: "test"}
|
47
|
+
)
|
48
|
+
```
|
49
|
+
|
50
|
+
### Post JSON as content
|
51
|
+
```ruby
|
52
|
+
res = http.post(url: "path/to/something", json: {some_argument: true})
|
53
|
+
```
|
40
54
|
|
55
|
+
## Delete requests
|
41
56
|
```ruby
|
42
|
-
http.
|
43
|
-
http.port => 80
|
57
|
+
res = http.delete(url: "path/to/something")
|
44
58
|
```
|
45
59
|
|
46
|
-
##
|
60
|
+
## File upload
|
61
|
+
```ruby
|
62
|
+
res = http.post_multipart(url: "path/to/something", post: {
|
63
|
+
"test_file1" => {
|
64
|
+
fpath: fpath,
|
65
|
+
filename: "specfile"
|
66
|
+
}
|
67
|
+
})
|
68
|
+
```
|
69
|
+
|
70
|
+
## Reading cookies
|
71
|
+
```ruby
|
72
|
+
puts "Cookies until now: #{http.cookies}"
|
73
|
+
```
|
74
|
+
|
75
|
+
## Building URL's
|
76
|
+
```ruby
|
77
|
+
ub = ::Http2::UrlBuilder.new
|
78
|
+
ub.host = "www.google.com"
|
79
|
+
ub.port = 80
|
80
|
+
ub.path = "script.php"
|
81
|
+
ub.params["some_param"] = 2
|
82
|
+
|
83
|
+
ub.build #=> "http://www.google.com/..."
|
84
|
+
ub.build_params #=> "some_param=2&some_other_param=..."
|
85
|
+
ub.build_path_and_params #=> "script.php?some_param=2"
|
86
|
+
ub.params? #=> true
|
87
|
+
ub.host #=> "www.google.com"
|
88
|
+
ub.port #=> 80
|
89
|
+
ub.path #=> "script.php"
|
90
|
+
```
|
91
|
+
|
92
|
+
## Inspecting responses
|
47
93
|
|
48
94
|
```ruby
|
49
95
|
resp = http.get("path/to/something")
|
@@ -58,6 +104,13 @@ resp.body #=> "<html><body>..."
|
|
58
104
|
resp.requested_url #=> "http://example.com/maybe/redirected/path/to/something"
|
59
105
|
```
|
60
106
|
|
107
|
+
## Get parameters later.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
http.host #=> example.com
|
111
|
+
http.port #=> 80
|
112
|
+
```
|
113
|
+
|
61
114
|
|
62
115
|
## Reconnect
|
63
116
|
|
data/Rakefile
CHANGED
@@ -11,20 +11,6 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "http2"
|
18
|
-
gem.homepage = "http://github.com/kaspernj/http2"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more.}
|
21
|
-
gem.description = %Q{A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more.}
|
22
|
-
gem.email = "k@spernj.org"
|
23
|
-
gem.authors = ["Kasper Johansen"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
14
|
require 'rspec/core'
|
29
15
|
require 'rspec/core/rake_task'
|
30
16
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
@@ -47,3 +33,5 @@ Rake::RDocTask.new do |rdoc|
|
|
47
33
|
rdoc.rdoc_files.include('README*')
|
48
34
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
35
|
end
|
36
|
+
|
37
|
+
Bundler::GemHelper.install_tasks
|
data/include/connection.rb
CHANGED
@@ -67,8 +67,8 @@ class Http2::Connection
|
|
67
67
|
elsif @args[:proxy]
|
68
68
|
connect_proxy
|
69
69
|
else
|
70
|
-
|
71
|
-
@sock_plain = TCPSocket.new(@
|
70
|
+
puts "Http2: Opening socket connection to '#{@http2.host}:#{@http2.port}'." if @debug
|
71
|
+
@sock_plain = TCPSocket.new(@http2.host, @http2.port)
|
72
72
|
end
|
73
73
|
|
74
74
|
if @args[:ssl]
|
data/include/post_request.rb
CHANGED
@@ -15,7 +15,7 @@ class Http2::PostRequest
|
|
15
15
|
|
16
16
|
@http2.mutex.synchronize do
|
17
17
|
puts "Http2: Doing post." if @debug
|
18
|
-
puts "Http2: Header str: #{
|
18
|
+
puts "Http2: Header str: #{header_string}" if @debug
|
19
19
|
|
20
20
|
@conn.write(header_string)
|
21
21
|
return @http2.read_response(@args)
|
@@ -56,8 +56,19 @@ private
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def headers
|
59
|
-
headers_hash = {
|
59
|
+
headers_hash = {
|
60
|
+
"Content-Length" => @data.bytesize,
|
61
|
+
"Content-Type" => content_type
|
62
|
+
}
|
60
63
|
headers_hash.merge! @http2.default_headers(@args)
|
64
|
+
|
65
|
+
unless headers_hash["Accept"]
|
66
|
+
if @args[:json]
|
67
|
+
headers_hash["Accept"] = "application/json"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return headers_hash
|
61
72
|
end
|
62
73
|
|
63
74
|
def header_string
|
data/include/response.rb
CHANGED
@@ -36,7 +36,21 @@ class Http2::Response
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def content_length
|
39
|
-
|
39
|
+
if header?("content-length")
|
40
|
+
header("content-length").to_i
|
41
|
+
elsif @body
|
42
|
+
return @body.bytesize
|
43
|
+
else
|
44
|
+
raise "Couldn't calculate content-length."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def content_type
|
49
|
+
if header?("content-type")
|
50
|
+
return header("content-type")
|
51
|
+
else
|
52
|
+
raise "No content-type was given."
|
53
|
+
end
|
40
54
|
end
|
41
55
|
|
42
56
|
#Returns the requested URL as a string.
|
@@ -53,6 +67,15 @@ class Http2::Response
|
|
53
67
|
validate_body_versus_content_length!
|
54
68
|
end
|
55
69
|
|
70
|
+
# Returns true if the result is JSON.
|
71
|
+
def json?
|
72
|
+
content_type == "application/json"
|
73
|
+
end
|
74
|
+
|
75
|
+
def json
|
76
|
+
@json ||= JSON.parse(body)
|
77
|
+
end
|
78
|
+
|
56
79
|
private
|
57
80
|
|
58
81
|
# Checks that the length of the body is the same as the given content-length if given.
|
data/include/response_reader.rb
CHANGED
@@ -74,7 +74,7 @@ class Http2::ResponseReader
|
|
74
74
|
private
|
75
75
|
|
76
76
|
def check_and_follow_redirect
|
77
|
-
if (@response.code == "302" || @response.code == "307") && @response.header?("location") && @http2.args[:follow_redirects]
|
77
|
+
if (@response.code == "302" || @response.code == "303" || @response.code == "307") && @response.header?("location") && @http2.args[:follow_redirects]
|
78
78
|
url, args = url_and_args_from_location
|
79
79
|
|
80
80
|
if !args[:host] || args[:host] == @args[:host]
|
data/include/url_builder.rb
CHANGED
data/lib/http2.rb
CHANGED
@@ -146,7 +146,7 @@ class Http2
|
|
146
146
|
host = args[:host] || self.host
|
147
147
|
port = args[:port] || self.port
|
148
148
|
|
149
|
-
headers["Host"] = host
|
149
|
+
headers["Host"] = "#{host}" # Copy host string to avoid changing the original string if port has been given!
|
150
150
|
headers["Host"] << ":#{port}" if port && ![80, 443].include?(port.to_i) && !@args[:skip_port_in_host_header]
|
151
151
|
headers["Accept-Encoding"] = "gzip" if @args[:encoding_gzip]
|
152
152
|
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Helpers
|
2
|
+
def with_webserver
|
3
|
+
require "hayabusa"
|
4
|
+
hayabusa = Hayabusa.new(
|
5
|
+
doc_root: "#{File.dirname(__FILE__)}/spec_root",
|
6
|
+
port: 3005
|
7
|
+
)
|
8
|
+
hayabusa.start
|
9
|
+
|
10
|
+
begin
|
11
|
+
yield(hayabusa)
|
12
|
+
ensure
|
13
|
+
hayabusa.stop
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_http(args = {})
|
18
|
+
with_webserver do |hayabusa|
|
19
|
+
Http2.new({host: "localhost", port: hayabusa.port, encoding_gzip: false}.merge(args)) do |http|
|
20
|
+
begin
|
21
|
+
yield http
|
22
|
+
rescue Http2::Errors::Internalserver => e
|
23
|
+
puts "Body of error-response: #{e.response.body}"
|
24
|
+
raise e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/http2/response_spec.rb
CHANGED
@@ -2,15 +2,15 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Http2::Response do
|
4
4
|
it "should register content type" do
|
5
|
-
|
6
|
-
res = http.get("content_type_test.
|
5
|
+
with_http do |http|
|
6
|
+
res = http.get("content_type_test.rhtml")
|
7
7
|
res.content_type.should eq "text/html"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should register content length" do
|
12
|
-
|
13
|
-
res = http.get("content_type_test.
|
12
|
+
with_http do |http|
|
13
|
+
res = http.get("content_type_test.rhtml")
|
14
14
|
res.content_length.should > 50
|
15
15
|
end
|
16
16
|
end
|
data/spec/http2_spec.rb
CHANGED
@@ -4,11 +4,11 @@ require "json"
|
|
4
4
|
describe "Http2" do
|
5
5
|
it "should be able to do normal post-requests." do
|
6
6
|
#Test posting keep-alive and advanced post-data.
|
7
|
-
|
7
|
+
with_http do |http|
|
8
8
|
0.upto(5) do
|
9
|
-
resp = http.get("multipart_test.
|
9
|
+
resp = http.get("multipart_test.rhtml")
|
10
10
|
|
11
|
-
resp = http.post(url: "multipart_test.
|
11
|
+
resp = http.post(url: "multipart_test.rhtml?choice=post-test", post: {
|
12
12
|
"val1" => "test1",
|
13
13
|
"val2" => "test2",
|
14
14
|
"val3" => [
|
@@ -31,33 +31,33 @@ describe "Http2" do
|
|
31
31
|
res.is_a?(Hash).should eq true
|
32
32
|
res["val1"].should eq "test1"
|
33
33
|
res["val2"].should eq "test2"
|
34
|
-
res["val3"][0].should eq "test3"
|
34
|
+
res["val3"]["0"].should eq "test3"
|
35
35
|
res["val4"]["val5"].should eq "test5"
|
36
|
-
res["val6"]["val7"][0]["val8"].should eq "test8"
|
37
|
-
res["val9"][0].should eq "a"
|
38
|
-
res["val9"][1].should eq "b"
|
39
|
-
res["val9"][2].should eq "d"
|
36
|
+
res["val6"]["val7"]["0"]["val8"].should eq "test8"
|
37
|
+
res["val9"]["0"].should eq "a"
|
38
|
+
res["val9"]["1"].should eq "b"
|
39
|
+
res["val9"]["2"].should eq "d"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
it "#reconnect" do
|
45
|
-
|
46
|
-
resp1 = http.get("multipart_test.
|
45
|
+
with_http(follow_redirects: false, encoding_gzip: false) do |http|
|
46
|
+
resp1 = http.get("multipart_test.rhtml")
|
47
47
|
http.reconnect
|
48
|
-
resp2 = http.get("multipart_test.
|
48
|
+
resp2 = http.get("multipart_test.rhtml")
|
49
49
|
|
50
50
|
resp1.body.should eq resp2.body
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should be able to do multipart-requests and keep-alive when using multipart." do
|
55
|
-
|
55
|
+
with_http(follow_redirects: false) do |http|
|
56
56
|
0.upto(5) do
|
57
57
|
fpath = File.realpath(__FILE__)
|
58
58
|
fpath2 = "#{File.realpath(File.dirname(__FILE__))}/../lib/http2.rb"
|
59
59
|
|
60
|
-
resp = http.post_multipart(url: "multipart_test.
|
60
|
+
resp = http.post_multipart(url: "multipart_test.rhtml", post: {
|
61
61
|
"test_var" => "true",
|
62
62
|
"test_file1" => {
|
63
63
|
fpath: fpath,
|
@@ -80,14 +80,11 @@ describe "Http2" do
|
|
80
80
|
|
81
81
|
it "it should be able to handle keep-alive correctly" do
|
82
82
|
urls = [
|
83
|
-
"
|
84
|
-
"
|
85
|
-
"?show=drinksdb",
|
86
|
-
"?show=forum&fid=9&tid=1917&page=0"
|
83
|
+
"content_type_test.rhtml",
|
84
|
+
"json_test.rhtml"
|
87
85
|
]
|
88
|
-
urls = ["robots.txt"]
|
89
86
|
|
90
|
-
|
87
|
+
with_http do |http|
|
91
88
|
0.upto(105) do |count|
|
92
89
|
url = urls[rand(urls.size)]
|
93
90
|
#print "Doing request #{count} of 200 (#{url}).\n"
|
@@ -103,53 +100,60 @@ describe "Http2" do
|
|
103
100
|
end
|
104
101
|
|
105
102
|
it "should raise exception when something is not found" do
|
106
|
-
|
107
|
-
|
108
|
-
http.get("something_that_does_not_exist.
|
109
|
-
|
110
|
-
|
103
|
+
with_http do |http|
|
104
|
+
expect{
|
105
|
+
http.get("something_that_does_not_exist.rhtml")
|
106
|
+
}.to raise_error(::Http2::Errors::Notfound)
|
107
|
+
end
|
111
108
|
end
|
112
109
|
|
113
110
|
it "should be able to post json" do
|
114
|
-
|
111
|
+
with_http do |http|
|
115
112
|
res = http.post(
|
116
|
-
url: "
|
113
|
+
url: "json_test.rhtml",
|
117
114
|
json: {testkey: "testvalue"}
|
118
115
|
)
|
119
116
|
|
120
117
|
data = JSON.parse(res.body)
|
121
|
-
data["_SERVER"]["
|
122
|
-
|
118
|
+
data["_SERVER"]["HTTP_CONTENT_TYPE"].should eq "application/json"
|
119
|
+
|
120
|
+
# Hack JSON data from Hayabusa.
|
121
|
+
json_data = JSON.parse(data["_POST"].keys.first)
|
122
|
+
json_data["testkey"].should eq "testvalue"
|
123
|
+
|
124
|
+
res.content_type.should eq "application/json"
|
125
|
+
res.json?.should eq true
|
126
|
+
res.json["_SERVER"]["REQUEST_METHOD"].should eq "POST"
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
126
130
|
it "should be able to post custom content types" do
|
127
|
-
|
128
|
-
|
129
|
-
Http2.new(host: "http2test.kaspernj.org") do |http|
|
131
|
+
with_http do |http|
|
130
132
|
res = http.post(
|
131
|
-
url: "content_type_test.
|
133
|
+
url: "content_type_test.rhtml",
|
132
134
|
content_type: "plain/text",
|
133
135
|
post: "test1_test2_test3"
|
134
136
|
)
|
135
137
|
|
136
138
|
data = JSON.parse(res.body)
|
137
|
-
data["_SERVER"]["
|
138
|
-
|
139
|
+
data["_SERVER"]["HTTP_CONTENT_TYPE"].should eq "plain/text"
|
140
|
+
|
141
|
+
raw_data = data["_POST"].keys.first
|
142
|
+
raw_data.should eq "test1_test2_test3"
|
139
143
|
end
|
140
144
|
end
|
141
145
|
|
142
146
|
it "should set various timeouts" do
|
143
|
-
|
144
|
-
res = http.get("content_type_test.
|
145
|
-
http.keepalive_timeout.should eq
|
146
|
-
http.keepalive_max.should eq
|
147
|
+
with_http do |http|
|
148
|
+
res = http.get("content_type_test.rhtml")
|
149
|
+
http.keepalive_timeout.should eq 15
|
150
|
+
http.keepalive_max.should eq 30
|
147
151
|
end
|
148
152
|
end
|
149
153
|
|
150
154
|
it "should follow redirects" do
|
151
|
-
|
152
|
-
resp = http.get("redirect_test.
|
155
|
+
with_http(follow_redirects: true) do |http|
|
156
|
+
resp = http.get("redirect_test.rhtml")
|
153
157
|
resp.code.should eq "200"
|
154
158
|
end
|
155
159
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
5
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
6
|
require 'rspec'
|
7
7
|
require 'http2'
|
8
|
+
require 'helpers'
|
8
9
|
|
9
10
|
# Requires supporting files with custom matchers and macros, etc,
|
10
11
|
# in ./support/ and its subdirectories.
|
@@ -14,4 +15,6 @@ RSpec.configure do |config|
|
|
14
15
|
config.expect_with :rspec do |c|
|
15
16
|
c.syntax = [:expect, :should]
|
16
17
|
end
|
18
|
+
|
19
|
+
config.include Helpers
|
17
20
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%
|
2
|
+
if _get["choice"] == "post-test"
|
3
|
+
print _post.to_json
|
4
|
+
elsif _get["choice"] == "file-test"
|
5
|
+
print File.read(_files["file"]["tmp_name"])
|
6
|
+
else
|
7
|
+
files = {}
|
8
|
+
files_hash = {}
|
9
|
+
|
10
|
+
_post.each do |key, val|
|
11
|
+
if val.is_a?(Hayabusa::Http_session::Post_multipart::File_upload)
|
12
|
+
files[key] = val.to_s
|
13
|
+
files_hash = {
|
14
|
+
"tmpname" => val.filename
|
15
|
+
}
|
16
|
+
|
17
|
+
_post[key] = {"tmpname" => val.filename}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
print JSON.generate(
|
22
|
+
"get" => _get,
|
23
|
+
"post" => _post,
|
24
|
+
"files" => files_hash,
|
25
|
+
"files_data" => files
|
26
|
+
)
|
27
|
+
end
|
28
|
+
%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-cases
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +81,47 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 1.0.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: hayabusa
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.25
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.0.25
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: codeclimate-test-reporter
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
72
114
|
requirements:
|
73
115
|
- - ">="
|
74
116
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
117
|
+
version: '0'
|
76
118
|
type: :development
|
77
119
|
prerelease: false
|
78
120
|
version_requirements: !ruby/object:Gem::Requirement
|
79
121
|
requirements:
|
80
122
|
- - ">="
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
124
|
+
version: '0'
|
83
125
|
description: A lightweight framework for doing http-connections in Ruby. Supports
|
84
126
|
cookies, keep-alive, compressing and much more.
|
85
127
|
email: k@spernj.org
|
@@ -89,15 +131,9 @@ extra_rdoc_files:
|
|
89
131
|
- LICENSE.txt
|
90
132
|
- README.md
|
91
133
|
files:
|
92
|
-
- ".document"
|
93
|
-
- ".rspec"
|
94
|
-
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
134
|
- LICENSE.txt
|
97
135
|
- README.md
|
98
136
|
- Rakefile
|
99
|
-
- VERSION
|
100
|
-
- http2.gemspec
|
101
137
|
- include/connection.rb
|
102
138
|
- include/errors.rb
|
103
139
|
- include/get_request.rb
|
@@ -109,12 +145,16 @@ files:
|
|
109
145
|
- include/url_builder.rb
|
110
146
|
- include/utils.rb
|
111
147
|
- lib/http2.rb
|
112
|
-
-
|
148
|
+
- spec/helpers.rb
|
113
149
|
- spec/http2/post_data_generator_spec.rb
|
114
150
|
- spec/http2/response_spec.rb
|
115
151
|
- spec/http2/url_builder_spec.rb
|
116
152
|
- spec/http2_spec.rb
|
117
153
|
- spec/spec_helper.rb
|
154
|
+
- spec/spec_root/content_type_test.rhtml
|
155
|
+
- spec/spec_root/json_test.rhtml
|
156
|
+
- spec/spec_root/multipart_test.rhtml
|
157
|
+
- spec/spec_root/redirect_test.rhtml
|
118
158
|
homepage: http://github.com/kaspernj/http2
|
119
159
|
licenses:
|
120
160
|
- MIT
|
@@ -140,4 +180,14 @@ signing_key:
|
|
140
180
|
specification_version: 4
|
141
181
|
summary: A lightweight framework for doing http-connections in Ruby. Supports cookies,
|
142
182
|
keep-alive, compressing and much more.
|
143
|
-
test_files:
|
183
|
+
test_files:
|
184
|
+
- spec/http2_spec.rb
|
185
|
+
- spec/http2/post_data_generator_spec.rb
|
186
|
+
- spec/http2/url_builder_spec.rb
|
187
|
+
- spec/http2/response_spec.rb
|
188
|
+
- spec/spec_root/redirect_test.rhtml
|
189
|
+
- spec/spec_root/json_test.rhtml
|
190
|
+
- spec/spec_root/multipart_test.rhtml
|
191
|
+
- spec/spec_root/content_type_test.rhtml
|
192
|
+
- spec/helpers.rb
|
193
|
+
- spec/spec_helper.rb
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem "string-cases"
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem "rspec", "~> 2.8.0"
|
9
|
-
gem "rdoc", "~> 3.12"
|
10
|
-
gem "bundler", ">= 1.0.0"
|
11
|
-
gem "jeweler", ">= 1.8.4"
|
12
|
-
end
|
13
|
-
|
14
|
-
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/Gemfile.lock
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.3.6)
|
5
|
-
builder (3.2.2)
|
6
|
-
codeclimate-test-reporter (0.4.0)
|
7
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
8
|
-
descendants_tracker (0.0.4)
|
9
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
10
|
-
diff-lcs (1.1.3)
|
11
|
-
docile (1.1.5)
|
12
|
-
faraday (0.9.0)
|
13
|
-
multipart-post (>= 1.2, < 3)
|
14
|
-
git (1.2.8)
|
15
|
-
github_api (0.12.0)
|
16
|
-
addressable (~> 2.3)
|
17
|
-
descendants_tracker (~> 0.0.4)
|
18
|
-
faraday (~> 0.8, < 0.10)
|
19
|
-
hashie (>= 3.2)
|
20
|
-
multi_json (>= 1.7.5, < 2.0)
|
21
|
-
nokogiri (~> 1.6.3)
|
22
|
-
oauth2
|
23
|
-
hashie (3.2.0)
|
24
|
-
highline (1.6.21)
|
25
|
-
jeweler (2.0.1)
|
26
|
-
builder
|
27
|
-
bundler (>= 1.0)
|
28
|
-
git (>= 1.2.5)
|
29
|
-
github_api
|
30
|
-
highline (>= 1.6.15)
|
31
|
-
nokogiri (>= 1.5.10)
|
32
|
-
rake
|
33
|
-
rdoc
|
34
|
-
json (1.8.1)
|
35
|
-
jwt (1.0.0)
|
36
|
-
mini_portile (0.6.0)
|
37
|
-
multi_json (1.10.1)
|
38
|
-
multi_xml (0.5.5)
|
39
|
-
multipart-post (2.0.0)
|
40
|
-
nokogiri (1.6.3.1)
|
41
|
-
mini_portile (= 0.6.0)
|
42
|
-
oauth2 (1.0.0)
|
43
|
-
faraday (>= 0.8, < 0.10)
|
44
|
-
jwt (~> 1.0)
|
45
|
-
multi_json (~> 1.3)
|
46
|
-
multi_xml (~> 0.5)
|
47
|
-
rack (~> 1.2)
|
48
|
-
rack (1.5.2)
|
49
|
-
rake (10.3.2)
|
50
|
-
rdoc (3.12.2)
|
51
|
-
json (~> 1.4)
|
52
|
-
rspec (2.8.0)
|
53
|
-
rspec-core (~> 2.8.0)
|
54
|
-
rspec-expectations (~> 2.8.0)
|
55
|
-
rspec-mocks (~> 2.8.0)
|
56
|
-
rspec-core (2.8.0)
|
57
|
-
rspec-expectations (2.8.0)
|
58
|
-
diff-lcs (~> 1.1.2)
|
59
|
-
rspec-mocks (2.8.0)
|
60
|
-
simplecov (0.9.0)
|
61
|
-
docile (~> 1.1.0)
|
62
|
-
multi_json
|
63
|
-
simplecov-html (~> 0.8.0)
|
64
|
-
simplecov-html (0.8.0)
|
65
|
-
string-cases (0.0.0)
|
66
|
-
thread_safe (0.3.4)
|
67
|
-
|
68
|
-
PLATFORMS
|
69
|
-
ruby
|
70
|
-
|
71
|
-
DEPENDENCIES
|
72
|
-
bundler (>= 1.0.0)
|
73
|
-
codeclimate-test-reporter
|
74
|
-
jeweler (>= 1.8.4)
|
75
|
-
rdoc (~> 3.12)
|
76
|
-
rspec (~> 2.8.0)
|
77
|
-
string-cases
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.29
|
data/http2.gemspec
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: http2 0.0.29 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "http2"
|
9
|
-
s.version = "0.0.29"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Kasper Johansen"]
|
14
|
-
s.date = "2014-12-04"
|
15
|
-
s.description = "A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more."
|
16
|
-
s.email = "k@spernj.org"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.md"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".rspec",
|
24
|
-
"Gemfile",
|
25
|
-
"Gemfile.lock",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.md",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"http2.gemspec",
|
31
|
-
"include/connection.rb",
|
32
|
-
"include/errors.rb",
|
33
|
-
"include/get_request.rb",
|
34
|
-
"include/post_data_generator.rb",
|
35
|
-
"include/post_multipart_request.rb",
|
36
|
-
"include/post_request.rb",
|
37
|
-
"include/response.rb",
|
38
|
-
"include/response_reader.rb",
|
39
|
-
"include/url_builder.rb",
|
40
|
-
"include/utils.rb",
|
41
|
-
"lib/http2.rb",
|
42
|
-
"shippable.yml",
|
43
|
-
"spec/http2/post_data_generator_spec.rb",
|
44
|
-
"spec/http2/response_spec.rb",
|
45
|
-
"spec/http2/url_builder_spec.rb",
|
46
|
-
"spec/http2_spec.rb",
|
47
|
-
"spec/spec_helper.rb"
|
48
|
-
]
|
49
|
-
s.homepage = "http://github.com/kaspernj/http2"
|
50
|
-
s.licenses = ["MIT"]
|
51
|
-
s.rubygems_version = "2.4.0"
|
52
|
-
s.summary = "A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more."
|
53
|
-
|
54
|
-
if s.respond_to? :specification_version then
|
55
|
-
s.specification_version = 4
|
56
|
-
|
57
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_runtime_dependency(%q<string-cases>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
60
|
-
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
-
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
62
|
-
s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
|
63
|
-
else
|
64
|
-
s.add_dependency(%q<string-cases>, [">= 0"])
|
65
|
-
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
66
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
67
|
-
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
68
|
-
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
69
|
-
end
|
70
|
-
else
|
71
|
-
s.add_dependency(%q<string-cases>, [">= 0"])
|
72
|
-
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
73
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
74
|
-
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
75
|
-
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|