cool.io-http 0.3.0 → 0.3.1
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/CHANGES.md +6 -0
- data/cool.io-http.gemspec +3 -3
- data/lib/cool.io-http/version.rb +1 -1
- data/lib/cool.io/http.rb +2 -2
- data/lib/cool.io/http_fiber.rb +3 -3
- data/test/test_http.rb +43 -23
- metadata +8 -7
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## cool.io-http 0.3.1 -- 2012-02-18
|
4
|
+
|
5
|
+
* Make sure Response#status is an integer
|
6
|
+
* Fixed a few bugs
|
7
|
+
* Return the response object in HttpFiber
|
8
|
+
|
3
9
|
## cool.io-http 0.3.0 -- 2012-01-09
|
4
10
|
|
5
11
|
* Introduced `Coolio::Http::Response`. So now instead of passing
|
data/cool.io-http.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "cool.io-http"
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-02-18"
|
10
10
|
s.description = "Simpler HTTP for [cool.io][]\n\n[cool.io]: https://github.com/tarcieri/cool.io"
|
11
11
|
s.email = ["godfat (XD) godfat.org"]
|
12
12
|
s.files = [
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"test/test_http.rb"]
|
31
31
|
s.homepage = "https://github.com/godfat/cool.io-http"
|
32
32
|
s.require_paths = ["lib"]
|
33
|
-
s.rubygems_version = "1.8.
|
33
|
+
s.rubygems_version = "1.8.16"
|
34
34
|
s.summary = "Simpler HTTP for [cool.io][]"
|
35
35
|
s.test_files = ["test/test_http.rb"]
|
36
36
|
|
data/lib/cool.io-http/version.rb
CHANGED
data/lib/cool.io/http.rb
CHANGED
@@ -34,7 +34,7 @@ class Coolio::Http < Coolio::HttpClient
|
|
34
34
|
:body => p.read, &block)
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.connect host, port, ssl
|
37
|
+
def self.connect host, port, ssl=false
|
38
38
|
http = super(host, port)
|
39
39
|
http.extend(Coolio::SSL) if ssl
|
40
40
|
http
|
@@ -66,7 +66,7 @@ class Coolio::Http < Coolio::HttpClient
|
|
66
66
|
super
|
67
67
|
@http_callback.call(Response.new(@http_data.join,
|
68
68
|
@http_response_header,
|
69
|
-
@http_response_header.http_status))
|
69
|
+
@http_response_header.http_status.to_i))
|
70
70
|
end
|
71
71
|
|
72
72
|
def on_connect
|
data/lib/cool.io/http_fiber.rb
CHANGED
@@ -4,9 +4,9 @@ require 'fiber'
|
|
4
4
|
class Coolio::HttpFiber < Coolio::Http
|
5
5
|
def self.request opts={}
|
6
6
|
f = Fiber.current
|
7
|
-
super(opts){ |response
|
8
|
-
yield(response
|
9
|
-
f.resume
|
7
|
+
super(opts){ |response|
|
8
|
+
yield(response) if block_given?
|
9
|
+
f.resume(response)
|
10
10
|
}
|
11
11
|
Fiber.yield
|
12
12
|
end
|
data/test/test_http.rb
CHANGED
@@ -1,33 +1,53 @@
|
|
1
1
|
|
2
|
+
require 'bacon'
|
2
3
|
require 'cool.io/http'
|
4
|
+
require 'rack'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
Bacon.summary_on_exit
|
7
|
+
port = rand(30000) + 1024
|
8
|
+
|
9
|
+
pid = Process.fork do
|
10
|
+
$stdout.reopen(IO::NULL)
|
11
|
+
$stderr.reopen(IO::NULL)
|
12
|
+
Rack::Handler::WEBrick.run(
|
13
|
+
lambda{ |env| [200, {'Content-Type' => 'test/ok'}, ['ok']] },
|
14
|
+
:Port => port)
|
15
|
+
end
|
16
|
+
sleep(0.5)
|
17
|
+
at_exit{ Process.kill 2, pid }
|
18
|
+
|
19
|
+
module Kernel
|
20
|
+
def eq? rhs
|
21
|
+
self == rhs
|
22
|
+
end
|
11
23
|
end
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
describe Coolio::Http do
|
26
|
+
def request klass, url
|
27
|
+
klass.request(:url => url){ |response| assert(response) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def assert response
|
31
|
+
response.body .should.eq 'ok'
|
32
|
+
response.headers['CONTENT_TYPE'].should.eq 'test/ok'
|
33
|
+
response.status .should.eq 200
|
34
|
+
end
|
35
|
+
|
36
|
+
should 'asynchrony' do
|
37
|
+
request(Coolio::Http, "http://localhost:#{port}")
|
38
|
+
Coolio::Loop.default.run
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'synchrony' do
|
42
|
+
Fiber.new{
|
43
|
+
assert(request(Coolio::HttpFiber, "http://localhost:#{port}"))
|
44
|
+
}.resume
|
45
|
+
Coolio::Loop.default.run
|
46
|
+
end
|
47
|
+
|
48
|
+
should 'ssl' do
|
28
49
|
sock = TCPSocket.new('localhost', port)
|
29
50
|
Coolio::Http.new(sock) .ssl?.should == false
|
30
51
|
Coolio::Http.new(sock).extend(Coolio::SSL).ssl?.should == true
|
31
|
-
serv.close
|
32
52
|
end
|
33
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cool.io-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cool.io
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153122400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153122400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mime-types
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153121580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153121580
|
36
36
|
description: ! 'Simpler HTTP for [cool.io][]
|
37
37
|
|
38
38
|
|
@@ -81,9 +81,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.16
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: Simpler HTTP for [cool.io][]
|
88
88
|
test_files:
|
89
89
|
- test/test_http.rb
|
90
|
+
has_rdoc:
|