http2 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/http2.gemspec +3 -3
- data/lib/http2.rb +14 -17
- metadata +17 -37
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
data/http2.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "http2"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.17"
|
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"]
|
12
|
-
s.date = "2013-06-
|
12
|
+
s.date = "2013-06-26"
|
13
13
|
s.description = "A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more."
|
14
14
|
s.email = "k@spernj.org"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.homepage = "http://github.com/kaspernj/http2"
|
37
37
|
s.licenses = ["MIT"]
|
38
38
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = "1.8.
|
39
|
+
s.rubygems_version = "1.8.11"
|
40
40
|
s.summary = "A lightweight framework for doing http-connections in Ruby. Supports cookies, keep-alive, compressing and much more."
|
41
41
|
|
42
42
|
if s.respond_to? :specification_version then
|
data/lib/http2.rb
CHANGED
@@ -26,7 +26,7 @@ class Http2
|
|
26
26
|
|
27
27
|
attr_reader :cookies, :args
|
28
28
|
|
29
|
-
VALID_ARGUMENTS_INITIALIZE = [:host, :port, :ssl, :nl, :user_agent, :raise_errors, :follow_redirects, :debug, :encoding_gzip, :autostate, :basic_auth, :extra_headers]
|
29
|
+
VALID_ARGUMENTS_INITIALIZE = [:host, :port, :ssl, :nl, :user_agent, :raise_errors, :follow_redirects, :debug, :encoding_gzip, :autostate, :basic_auth, :extra_headers, :proxy]
|
30
30
|
def initialize(args = {})
|
31
31
|
args = {:host => args} if args.is_a?(String)
|
32
32
|
raise "Arguments wasnt a hash." if !args.is_a?(Hash)
|
@@ -147,27 +147,26 @@ class Http2
|
|
147
147
|
@charset = nil
|
148
148
|
|
149
149
|
#Open connection.
|
150
|
-
if @args[:proxy]
|
150
|
+
if @args[:proxy] && @args[:ssl]
|
151
151
|
print "Http2: Initializing proxy stuff.\n" if @debug
|
152
152
|
@sock_plain = TCPSocket.new(@args[:proxy][:host], @args[:proxy][:port])
|
153
|
-
@sock = @sock_plain
|
154
153
|
|
155
|
-
@
|
156
|
-
@
|
154
|
+
@sock_plain.write("CONNECT #{@args[:host]}:#{@args[:port]} HTTP/1.0#{@nl}")
|
155
|
+
@sock_plain.write("User-Agent: #{@uagent}#{@nl}")
|
157
156
|
|
158
157
|
if @args[:proxy][:user] and @args[:proxy][:passwd]
|
159
158
|
credential = ["#{@args[:proxy][:user]}:#{@args[:proxy][:passwd]}"].pack("m")
|
160
159
|
credential.delete!("\r\n")
|
161
|
-
@
|
160
|
+
@sock_plain.write("Proxy-Authorization: Basic #{credential}#{@nl}")
|
162
161
|
end
|
163
162
|
|
164
|
-
@
|
163
|
+
@sock_plain.write(@nl)
|
165
164
|
|
166
|
-
res = @
|
165
|
+
res = @sock_plain.gets
|
167
166
|
raise res if res.to_s.downcase != "http/1.0 200 connection established#{@nl}"
|
168
|
-
|
169
|
-
|
170
|
-
|
167
|
+
elsif @args[:proxy]
|
168
|
+
print "Http2: Opening socket connection to '#{@args[:host]}:#{@args[:port]}' through proxy '#{@args[:proxy][:host]}:#{@args[:proxy][:port]}'.\n" if @debug
|
169
|
+
@sock_plain = TCPSocket.new(@args[:proxy][:host], @args[:proxy][:port].to_i)
|
171
170
|
else
|
172
171
|
print "Http2: Opening socket connection to '#{@args[:host]}:#{@args[:port]}'.\n" if @debug
|
173
172
|
@sock_plain = TCPSocket.new(@args[:host], @args[:port].to_i)
|
@@ -280,11 +279,9 @@ class Http2
|
|
280
279
|
}
|
281
280
|
|
282
281
|
#Possible to give custom host-argument.
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
headers["Host"] = @args[:host]
|
287
|
-
end
|
282
|
+
_args = args[:host] ? args : @args
|
283
|
+
headers["Host"] = _args[:host]
|
284
|
+
headers["Host"] += ":#{_args[:port]}" unless _args[:port] && [80,443].include?(_args[:port].to_i)
|
288
285
|
|
289
286
|
if !@args.key?(:encoding_gzip) or @args[:encoding_gzip]
|
290
287
|
headers["Accept-Encoding"] = "gzip"
|
@@ -386,7 +383,7 @@ class Http2
|
|
386
383
|
puts "Doing post." if @debug
|
387
384
|
|
388
385
|
header_str = "#{method} /#{args[:url]} HTTP/1.1#{@nl}"
|
389
|
-
header_str << self.header_str({"Content-Length" => praw.
|
386
|
+
header_str << self.header_str({"Content-Length" => praw.bytesize, "Content-Type" => content_type}.merge(self.default_headers(args)), args)
|
390
387
|
header_str << @nl
|
391
388
|
header_str << praw
|
392
389
|
header_str << @nl
|
metadata
CHANGED
@@ -1,80 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.17
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
15
|
+
name: rspec
|
16
|
+
requirement: &9884720 !ruby/object:Gem::Requirement
|
16
17
|
none: false
|
17
18
|
requirements:
|
18
19
|
- - ~>
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: 2.8.0
|
21
|
-
name: rspec
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.8.0
|
24
|
+
version_requirements: *9884720
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
26
|
+
name: rdoc
|
27
|
+
requirement: &9883900 !ruby/object:Gem::Requirement
|
32
28
|
none: false
|
33
29
|
requirements:
|
34
30
|
- - ~>
|
35
31
|
- !ruby/object:Gem::Version
|
36
32
|
version: '3.12'
|
37
|
-
name: rdoc
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '3.12'
|
35
|
+
version_requirements: *9883900
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
37
|
+
name: bundler
|
38
|
+
requirement: &9882980 !ruby/object:Gem::Requirement
|
48
39
|
none: false
|
49
40
|
requirements:
|
50
41
|
- - ! '>='
|
51
42
|
- !ruby/object:Gem::Version
|
52
43
|
version: 1.0.0
|
53
|
-
name: bundler
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0
|
46
|
+
version_requirements: *9882980
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
48
|
+
name: jeweler
|
49
|
+
requirement: &9881920 !ruby/object:Gem::Requirement
|
64
50
|
none: false
|
65
51
|
requirements:
|
66
52
|
- - ~>
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: 1.8.4
|
69
|
-
name: jeweler
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 1.8.4
|
57
|
+
version_requirements: *9881920
|
78
58
|
description: A lightweight framework for doing http-connections in Ruby. Supports
|
79
59
|
cookies, keep-alive, compressing and much more.
|
80
60
|
email: k@spernj.org
|
@@ -111,10 +91,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
91
|
requirements:
|
112
92
|
- - ! '>='
|
113
93
|
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
114
95
|
segments:
|
115
96
|
- 0
|
116
|
-
hash:
|
117
|
-
version: '0'
|
97
|
+
hash: 1747882727937754556
|
118
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
99
|
none: false
|
120
100
|
requirements:
|
@@ -123,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
103
|
version: '0'
|
124
104
|
requirements: []
|
125
105
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.11
|
127
107
|
signing_key:
|
128
108
|
specification_version: 3
|
129
109
|
summary: A lightweight framework for doing http-connections in Ruby. Supports cookies,
|