rack-proxy 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rack/http_streaming_response.rb +13 -0
- data/rack-proxy.gemspec +2 -2
- data/test/http_streaming_response_test.rb +19 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -26,12 +26,25 @@ module Rack
|
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
29
|
+
# Can be called only once!
|
29
30
|
def each(&block)
|
30
31
|
response.read_body(&block)
|
31
32
|
ensure
|
32
33
|
session.end_request_hacked
|
33
34
|
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
@body ||= begin
|
38
|
+
lines = []
|
39
|
+
|
40
|
+
each do |line|
|
41
|
+
lines << line
|
42
|
+
end
|
34
43
|
|
44
|
+
lines.join
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
35
48
|
protected
|
36
49
|
|
37
50
|
# Net::HTTPResponse
|
data/rack-proxy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-proxy}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jacek Becela"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-15}
|
13
13
|
s.description = %q{A Rack app that provides request/response rewriting proxy capabilities with streaming.}
|
14
14
|
s.email = %q{jacek.becela@gmail.com}
|
15
15
|
s.files = [
|
@@ -3,16 +3,17 @@ require "rack/http_streaming_response"
|
|
3
3
|
|
4
4
|
class HttpStreamingResponseTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
def
|
6
|
+
def setup
|
7
7
|
host, req = "trix.pl", Net::HTTP::Get.new("/")
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
@response = Rack::HttpStreamingResponse.new(req, host)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_streaming
|
11
12
|
# Response status
|
12
|
-
assert response.status == 200
|
13
|
+
assert @response.status == 200
|
13
14
|
|
14
15
|
# Headers
|
15
|
-
headers = response.headers
|
16
|
+
headers = @response.headers
|
16
17
|
|
17
18
|
assert headers.size > 0
|
18
19
|
assert headers["content-type"] == "text/html"
|
@@ -21,7 +22,7 @@ class HttpStreamingResponseTest < Test::Unit::TestCase
|
|
21
22
|
|
22
23
|
# Body
|
23
24
|
chunks = []
|
24
|
-
response.body.each do |chunk|
|
25
|
+
@response.body.each do |chunk|
|
25
26
|
chunks << chunk
|
26
27
|
end
|
27
28
|
|
@@ -29,6 +30,17 @@ class HttpStreamingResponseTest < Test::Unit::TestCase
|
|
29
30
|
chunks.each do |chunk|
|
30
31
|
assert chunk.is_a?(String)
|
31
32
|
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_to_s
|
38
|
+
assert_equal @response.headers["Content-Length"].to_i, @response.body.to_s.size
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_to_s_called_twice
|
42
|
+
body = @response.body
|
43
|
+
assert_equal body.to_s, body.to_s
|
32
44
|
end
|
33
45
|
|
34
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacek Becela
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-15 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|