em-net-http 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/em-net-http.gemspec +1 -3
- data/lib/em-net-http.rb +17 -9
- data/spec/em-net-http_spec.rb +132 -71
- metadata +21 -21
- data/spec/spec_helper.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38af6438fd2b8255ce7756ad1bf1a313b3b1fcef
|
4
|
+
data.tar.gz: df1038c3a426d3733a714233ec956719c519070a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f521f421707ec1a8342f01bda1af50018779bb0961509f3e064196c4f99d8cfe0ff051a7ada8b6a5ad47c944c30d25e2fc4edc55fdae006b5e1272bfecc0ec7b
|
7
|
+
data.tar.gz: 488044d712388932f55dc0c78da40d2bb6e0b68c9e19aea0d044f6715430b3df765e02b4c22f52f538d470e7f23c80801d7ae3a9eb3417a97919f53aa6790561
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.10
|
data/em-net-http.gemspec
CHANGED
@@ -26,8 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"lib/test_weary.rb",
|
27
27
|
"spec/em-net-http_spec.rb",
|
28
28
|
"spec/image.jpg",
|
29
|
-
"spec/spec.opts"
|
30
|
-
"spec/spec_helper.rb"
|
29
|
+
"spec/spec.opts"
|
31
30
|
]
|
32
31
|
s.homepage = %q{http://github.com/jfairbairn/em-net-http}
|
33
32
|
s.require_paths = ["lib"]
|
@@ -41,4 +40,3 @@ Gem::Specification.new do |s|
|
|
41
40
|
s.add_development_dependency(%q<mimic>, [">= 0.3.0"])
|
42
41
|
s.add_development_dependency(%q<weary>, [">= 0"])
|
43
42
|
end
|
44
|
-
|
data/lib/em-net-http.rb
CHANGED
@@ -126,6 +126,7 @@ module Net
|
|
126
126
|
sslopts[:cert_chain_file] = ca_file if ca_file
|
127
127
|
end
|
128
128
|
opts[:timeout] = self.read_timeout
|
129
|
+
opts[:decoding] = false
|
129
130
|
|
130
131
|
headers = opts[:head] = {}
|
131
132
|
req.each do |k, v|
|
@@ -135,8 +136,10 @@ module Net
|
|
135
136
|
headers['content-type'] ||= "application/x-www-form-urlencoded"
|
136
137
|
|
137
138
|
t0 = Time.now
|
139
|
+
http = EM::HttpRequest.new(uri)
|
138
140
|
request_method = (req.respond_to?(:method) ? req.method : req.class::METHOD).downcase.to_sym
|
139
|
-
|
141
|
+
request_method = :"a#{request_method}" if http.respond_to?(:"a#{request_method}")
|
142
|
+
httpreq = http.send(request_method, opts)
|
140
143
|
|
141
144
|
f=Fiber.current
|
142
145
|
|
@@ -146,7 +149,11 @@ module Net
|
|
146
149
|
nhresclass = Net::HTTPResponse.response_class(emres.code)
|
147
150
|
nhres = nhresclass.new(emres.http_version, emres.code, emres.message)
|
148
151
|
emres.to_hash.each do |k, v|
|
149
|
-
|
152
|
+
if v.is_a?(Array)
|
153
|
+
v.each {|e| nhres.add_field(k, e)}
|
154
|
+
else
|
155
|
+
nhres.add_field(k, v)
|
156
|
+
end
|
150
157
|
end
|
151
158
|
nhres.body = emres.body if req.response_body_permitted? && nhresclass.body_permitted?
|
152
159
|
nhres.instance_variable_set '@read', true
|
@@ -161,11 +168,15 @@ module Net
|
|
161
168
|
nhresclass = Net::HTTPResponse.response_class(emres.code)
|
162
169
|
nhres = nhresclass.new(emres.http_version, emres.code, emres.message)
|
163
170
|
emres.to_hash.each do |k, v|
|
164
|
-
|
171
|
+
if v.is_a?(Array)
|
172
|
+
v.each {|e| nhres.add_field(k, e)}
|
173
|
+
else
|
174
|
+
nhres.add_field(k, v)
|
175
|
+
end
|
165
176
|
end
|
166
177
|
f.resume nhres
|
167
178
|
}
|
168
|
-
httpreq.errback {|err|f.resume(
|
179
|
+
httpreq.errback {|err|f.resume(err)}
|
169
180
|
|
170
181
|
nhres = yield_with_error_check(t0)
|
171
182
|
nhres.instance_variable_set :@httpreq, httpreq
|
@@ -174,7 +185,7 @@ module Net
|
|
174
185
|
nhres
|
175
186
|
else
|
176
187
|
httpreq.callback &convert_em_http_response
|
177
|
-
httpreq.errback {|err|f.resume(
|
188
|
+
httpreq.errback {|err|f.resume(err)}
|
178
189
|
|
179
190
|
yield_with_error_check(t0)
|
180
191
|
end
|
@@ -185,10 +196,7 @@ module Net
|
|
185
196
|
def yield_with_error_check(t0)
|
186
197
|
res = Fiber.yield
|
187
198
|
|
188
|
-
if res ==
|
189
|
-
raise 'EM::HttpRequest error - request timed out' if Time.now - self.read_timeout > t0
|
190
|
-
raise 'EM::HttpRequest error - unknown error'
|
191
|
-
end
|
199
|
+
raise res.error if res.class == EM::HttpClient
|
192
200
|
|
193
201
|
res
|
194
202
|
end
|
data/spec/em-net-http_spec.rb
CHANGED
@@ -1,94 +1,155 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'em-net-http'
|
4
|
+
require 'time'
|
5
|
+
require 'rspec'
|
6
|
+
require 'mimic'
|
2
7
|
|
3
8
|
describe "em-net-http" do
|
9
|
+
around(:each) do |example|
|
10
|
+
Fiber.new do
|
11
|
+
example.run
|
12
|
+
end.resume
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '' do
|
16
|
+
before(:all) do
|
17
|
+
Mimic.mimic do
|
18
|
+
Net::HTTPResponse::CODE_TO_OBJ.each do |code, klass|
|
19
|
+
get("/code/#{code}").returning("#{code} #{klass.name}", code.to_i, {})
|
20
|
+
end
|
4
21
|
|
5
|
-
|
6
|
-
assert_identical(:streamed => true) {
|
7
|
-
body = StringIO.new '', 'wb'
|
22
|
+
get('/hello').returning('Hello World!', 200, {'Content-Type'=>'text/plain'})
|
8
23
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
24
|
+
class BigImageResponse
|
25
|
+
def each
|
26
|
+
::File.open('spec/image.jpg', "rb") { |file|
|
27
|
+
while part = file.read(8192)
|
28
|
+
yield part
|
29
|
+
end
|
30
|
+
}
|
31
|
+
end
|
14
32
|
end
|
15
|
-
|
16
|
-
resp
|
17
|
-
end
|
18
|
-
}
|
19
|
-
end
|
33
|
+
resp = BigImageResponse.new
|
34
|
+
get('/image').returning(resp, 200, {"Content-Type" => 'image/jpeg'})
|
20
35
|
|
21
|
-
|
22
|
-
|
23
|
-
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
24
|
-
respone = http.request_get "/image" do |resp|
|
25
|
-
resp.should be_a_kind_of(Net::HTTPOK)
|
26
|
-
resp.read_body # force reading the body before the test tears down the EM loop
|
27
|
-
resp
|
36
|
+
post('/testpost') do
|
37
|
+
"You said #{request.body.read}."
|
28
38
|
end
|
29
|
-
respone.tap { respone.should be_a_kind_of(Net::HTTPOK) }
|
30
39
|
end
|
31
|
-
|
32
|
-
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should support streaming the response' do
|
43
|
+
assert_identical(true) {
|
44
|
+
body = StringIO.new '', 'wb'
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
46
|
+
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
47
|
+
http.request_get "/image" do |resp|
|
48
|
+
resp.should be_a_kind_of(Net::HTTPOK)
|
49
|
+
resp.read_body { |chunk| body.write chunk }
|
50
|
+
resp
|
51
|
+
end
|
52
|
+
end.tap do |resp|
|
53
|
+
resp.instance_variable_set :@streamed_body, body.string
|
54
|
+
end
|
55
|
+
}
|
38
56
|
end
|
39
57
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
58
|
+
it 'should support buffering the response' do
|
59
|
+
assert_identical {
|
60
|
+
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
61
|
+
respone = http.request_get "/image" do |resp|
|
62
|
+
resp.should be_a_kind_of(Net::HTTPOK)
|
63
|
+
resp.read_body # force reading the body before the test tears down the EM loop
|
64
|
+
resp
|
65
|
+
end
|
66
|
+
respone.tap { respone.should be_a_kind_of(Net::HTTPOK) }
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'should be compatible' do
|
72
|
+
it 'with Net::HTTP.get()' do
|
73
|
+
run_requests {Net::HTTP.get(URI.parse("http://localhost:#{Mimic::MIMIC_DEFAULT_PORT}/hello"))}
|
74
|
+
@expected_res.should == @actual_res
|
75
|
+
end
|
44
76
|
|
45
|
-
|
46
|
-
|
47
|
-
|
77
|
+
# it 'for Net::HTTP.get_print()' do
|
78
|
+
# run_requests {Net::HTTP.get_print(URI.parse('http://localhost/hello'))}
|
79
|
+
# @expected_res.should == @actual_res
|
80
|
+
# end
|
81
|
+
|
82
|
+
# We don't test responses like 100 Continue at the moment.
|
83
|
+
%w(200 201 202 203 204 205 206 300 301 302 303 307 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505).each do |code|
|
84
|
+
it "with Net::HTTP.start(host, port, &block) with response code #{code}" do
|
85
|
+
assert_identical {
|
86
|
+
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
87
|
+
http.get("/code/#{code}").tap { |resp|
|
88
|
+
# Force the response to be buffered while we are still in the EM loop, since we shut it down EM before the verifications
|
89
|
+
resp.body
|
90
|
+
}
|
91
|
+
end
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "with Net::HTTP.new(host, port).start(&block) with response code #{code}" do
|
96
|
+
assert_identical {
|
97
|
+
h = Net::HTTP.new('localhost', Mimic::MIMIC_DEFAULT_PORT)
|
98
|
+
h.start do |http|
|
99
|
+
http.get("/code/#{code}")
|
100
|
+
end
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it "with response code 304" do
|
48
106
|
assert_identical {
|
49
107
|
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
108
|
+
req = Net::HTTP::Get.new('/code/304')
|
109
|
+
req['If-Modified-Since'] = Time.now.rfc2822
|
110
|
+
http.request(req)
|
54
111
|
end
|
55
112
|
}
|
113
|
+
|
56
114
|
end
|
57
|
-
|
58
|
-
it
|
115
|
+
|
116
|
+
it 'with post' do
|
59
117
|
assert_identical {
|
60
|
-
|
61
|
-
|
62
|
-
|
118
|
+
Net::HTTP.start('localhost', Mimic::MIMIC_DEFAULT_PORT) do |http|
|
119
|
+
req = Net::HTTP::Post.new('/testpost')
|
120
|
+
req.body = 'hello mimic'
|
121
|
+
http.request(req)
|
63
122
|
end
|
64
123
|
}
|
124
|
+
|
65
125
|
end
|
126
|
+
|
66
127
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
req['If-Modified-Since'] = Time.now.rfc2822
|
73
|
-
http.request(req)
|
74
|
-
end
|
75
|
-
}
|
76
|
-
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
after(:all) do
|
132
|
+
Mimic.cleanup!
|
77
133
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should raise relevant exceptions' do
|
138
|
+
EM.run do
|
139
|
+
Fiber.new do
|
140
|
+
begin
|
141
|
+
Net::HTTP.start('localhost', 1) do |r|
|
142
|
+
r.get('/')
|
143
|
+
end
|
144
|
+
fail('expected exception to be raised')
|
145
|
+
rescue => expected
|
146
|
+
expected.class.should == Errno::ECONNREFUSED
|
147
|
+
EM.stop_event_loop
|
85
148
|
end
|
86
|
-
|
87
|
-
|
149
|
+
end.resume
|
88
150
|
end
|
89
|
-
|
90
151
|
end
|
91
|
-
|
152
|
+
|
92
153
|
def run_requests(&block)
|
93
154
|
@expected_res = yield
|
94
155
|
EM.run do
|
@@ -100,23 +161,23 @@ describe "em-net-http" do
|
|
100
161
|
end
|
101
162
|
end
|
102
163
|
end
|
103
|
-
|
164
|
+
|
104
165
|
def assert_identical(streamed=false, &block)
|
105
166
|
run_requests(&block)
|
106
167
|
@actual_res.should be_a_kind_of(Net::HTTPResponse)
|
107
|
-
@actual_res.should match_response(@expected_res,
|
168
|
+
@actual_res.should match_response(@expected_res, streamed)
|
108
169
|
end
|
109
|
-
|
170
|
+
|
110
171
|
def match_response(expected, streamed=false)
|
111
172
|
ResponseMatcher.new(expected, streamed)
|
112
173
|
end
|
113
|
-
|
174
|
+
|
114
175
|
class ResponseMatcher
|
115
176
|
def initialize(expected, streamed=false)
|
116
177
|
@expected = expected
|
117
178
|
@streamed = streamed
|
118
179
|
end
|
119
|
-
|
180
|
+
|
120
181
|
def matches?(actual)
|
121
182
|
# Dates could differ slightly :(
|
122
183
|
expected_date = Time.parse(@expected.delete('date').join)
|
@@ -136,6 +197,6 @@ describe "em-net-http" do
|
|
136
197
|
end
|
137
198
|
true
|
138
199
|
end
|
139
|
-
|
200
|
+
|
140
201
|
end
|
141
202
|
end
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-net-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fairbairn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: eventmachine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.12.10
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.12.10
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: addressable
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: em-http-request
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.2.10
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.2.10
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mimic
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.3.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.3.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: weary
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Monkeypatching Net::HTTP to use em-http-request under the hood.
|
@@ -116,7 +116,7 @@ extra_rdoc_files:
|
|
116
116
|
- LICENSE
|
117
117
|
- README.md
|
118
118
|
files:
|
119
|
-
- .document
|
119
|
+
- ".document"
|
120
120
|
- Gemfile
|
121
121
|
- LICENSE
|
122
122
|
- README.md
|
@@ -130,7 +130,6 @@ files:
|
|
130
130
|
- spec/em-net-http_spec.rb
|
131
131
|
- spec/image.jpg
|
132
132
|
- spec/spec.opts
|
133
|
-
- spec/spec_helper.rb
|
134
133
|
homepage: http://github.com/jfairbairn/em-net-http
|
135
134
|
licenses: []
|
136
135
|
metadata: {}
|
@@ -140,18 +139,19 @@ require_paths:
|
|
140
139
|
- lib
|
141
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
141
|
requirements:
|
143
|
-
- -
|
142
|
+
- - ">="
|
144
143
|
- !ruby/object:Gem::Version
|
145
144
|
version: '0'
|
146
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
146
|
requirements:
|
148
|
-
- -
|
147
|
+
- - ">="
|
149
148
|
- !ruby/object:Gem::Version
|
150
149
|
version: '0'
|
151
150
|
requirements: []
|
152
151
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.4.5.1
|
154
153
|
signing_key:
|
155
154
|
specification_version: 4
|
156
155
|
summary: Non-blocking replacement for Net::HTTP, for use in EventMachine
|
157
156
|
test_files: []
|
157
|
+
has_rdoc:
|
data/spec/spec_helper.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'em-net-http'
|
4
|
-
require 'time'
|
5
|
-
require 'rspec'
|
6
|
-
|
7
|
-
require 'mimic'
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.before(:all) do
|
11
|
-
Mimic.mimic do
|
12
|
-
Net::HTTPResponse::CODE_TO_OBJ.each do |code, klass|
|
13
|
-
get("/code/#{code}").returning("#{code} #{klass.name}", code.to_i, {})
|
14
|
-
end
|
15
|
-
|
16
|
-
get('/hello').returning('Hello World!', 200, {'Content-Type'=>'text/plain'})
|
17
|
-
|
18
|
-
class BigImageResponse
|
19
|
-
def each
|
20
|
-
::File.open('spec/image.jpg', "rb") { |file|
|
21
|
-
while part = file.read(8192)
|
22
|
-
yield part
|
23
|
-
end
|
24
|
-
}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
resp = BigImageResponse.new
|
28
|
-
get('/image').returning(resp, 200, {"Content-Type" => 'image/jpeg'})
|
29
|
-
|
30
|
-
post('/testpost') do
|
31
|
-
"You said #{request.body.read}."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
config.after(:all) do
|
37
|
-
Mimic.cleanup!
|
38
|
-
end
|
39
|
-
end
|