http2 0.0.3 → 0.0.4
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 +17 -5
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/http2.gemspec
CHANGED
data/lib/http2.rb
CHANGED
@@ -156,13 +156,25 @@ class Http2
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
#Forces various stuff into arguments like URL.
|
159
|
+
#Forces various stuff into arguments-hash like URL from original arguments and enables single-string-shortcuts and more.
|
160
160
|
def parse_args(*args)
|
161
161
|
if args.length == 1 and args.first.is_a?(String)
|
162
|
-
|
162
|
+
args = {:url => args.first}
|
163
|
+
elsif args.length >= 2
|
164
|
+
raise "Couldnt parse arguments."
|
165
|
+
elsif args.is_a?(Array) and args.length == 1
|
166
|
+
args = args.first
|
167
|
+
else
|
168
|
+
raise "Invalid arguments: '#{args.class.name}'."
|
169
|
+
end
|
170
|
+
|
171
|
+
if args[:url].to_s.strip.empty?
|
172
|
+
raise "Empty URL given: '#{args[:url]}'."
|
173
|
+
elsif args[:url].to_s.split("\n").length > 1
|
174
|
+
raise "Multiple lines given in URL: '#{args[:url]}'."
|
163
175
|
end
|
164
176
|
|
165
|
-
return args
|
177
|
+
return args
|
166
178
|
end
|
167
179
|
|
168
180
|
#Returns a result-object based on the arguments.
|
@@ -170,7 +182,7 @@ class Http2
|
|
170
182
|
# res = http.get("somepage.html")
|
171
183
|
# print res.body #=> <String>-object containing the HTML gotten.
|
172
184
|
def get(args)
|
173
|
-
args = parse_args(args)
|
185
|
+
args = self.parse_args(args)
|
174
186
|
|
175
187
|
header_str = "GET /#{args[:url]} HTTP/1.1#{@nl}"
|
176
188
|
header_str << self.header_str(self.default_headers(args), args)
|
@@ -447,7 +459,7 @@ class Http2
|
|
447
459
|
break if line.to_s == ""
|
448
460
|
|
449
461
|
if @mode == "headers" and line == @nl
|
450
|
-
print "Changing mode to body!\n" if @debug
|
462
|
+
print "Http2: Changing mode to body!\n" if @debug
|
451
463
|
break if @length == 0
|
452
464
|
@mode = "body"
|
453
465
|
next
|
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.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
hash: -
|
110
|
+
hash: -4193336568460171826
|
111
111
|
segments:
|
112
112
|
- 0
|
113
113
|
version: "0"
|