fishwife 1.2.0-java → 1.3.0-java
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/History.rdoc +7 -0
- data/Manifest.txt +3 -0
- data/example/config.ru +0 -2
- data/example/giant.ru +28 -0
- data/lib/fishwife.rb +6 -0
- data/lib/fishwife/base.rb +2 -1
- data/lib/fishwife/fishwife-1.3.0.jar +0 -0
- data/lib/fishwife/rack_servlet.rb +14 -20
- data/pom.xml +52 -0
- data/spec/fishwife_spec.rb +2 -2
- data/spec/spec_helper.rb +17 -0
- data/spec/test_app.rb +5 -6
- metadata +6 -3
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 1.3.0 (2012-2-12)
|
2
|
+
* Add OutputUtil JRuby java extension for write_body and
|
3
|
+
write_file. This increases single threaded output performance from
|
4
|
+
78Mb/s to 238Mb/s on my dev. host using curl against the included
|
5
|
+
example/giant.ru test app.
|
6
|
+
* Upgrade to rack ~> 1.4.1
|
7
|
+
|
1
8
|
=== 1.2.0 (2012-1-29)
|
2
9
|
* Upgrade, widen to rjack-jetty >= 7.5.4, < 7.7 (incl. 7.6.0.0 release)
|
3
10
|
* Fixed, tests passing in 1.9 mode; at least with jruby pre-release
|
data/Manifest.txt
CHANGED
@@ -3,8 +3,10 @@ LICENSE
|
|
3
3
|
Manifest.txt
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
|
+
pom.xml
|
6
7
|
bin/fishwife
|
7
8
|
example/config.ru
|
9
|
+
example/giant.ru
|
8
10
|
lib/fishwife/base.rb
|
9
11
|
lib/fishwife.rb
|
10
12
|
lib/fishwife/http_server.rb
|
@@ -15,3 +17,4 @@ spec/spec_helper.rb
|
|
15
17
|
spec/test_app.rb
|
16
18
|
spec/data/hello.txt
|
17
19
|
spec/data/reddit-icon.png
|
20
|
+
lib/fishwife/fishwife-1.3.0.jar
|
data/example/config.ru
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
require 'rjack-logback'
|
8
8
|
RJack::Logback.config_console( :stderr => true, :thread => true )
|
9
9
|
|
10
|
-
# FIXME: Currently Need Content-Length set to avoid double chunked
|
11
|
-
# transfer-encoding with rack 1.3 (not a problem in rack 1.2)!
|
12
10
|
use Rack::ContentLength
|
13
11
|
|
14
12
|
run lambda { |env| [200, { "Content-Type" => "text/plain" }, ["Hello"]] }
|
data/example/giant.ru
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#\ -s Fishwife -p 9297 -E production
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rjack-logback'
|
5
|
+
RJack::Logback.config_console( :stderr => true, :thread => true )
|
6
|
+
|
7
|
+
class GiantGenerator
|
8
|
+
FILLER = <<-END
|
9
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
10
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
11
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
12
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
13
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
14
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
15
|
+
END
|
16
|
+
|
17
|
+
def each
|
18
|
+
loop { yield FILLER[0..rand( FILLER.size)] }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class App
|
23
|
+
def call( env )
|
24
|
+
[ 200, { 'Content-Type' => 'text/plain' }, GiantGenerator.new ]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
run App.new
|
data/lib/fishwife.rb
CHANGED
@@ -23,6 +23,12 @@ require 'rjack-slf4j'
|
|
23
23
|
# Load Jetty JARs.
|
24
24
|
require 'rjack-jetty'
|
25
25
|
|
26
|
+
require 'fishwife/base'
|
27
|
+
|
28
|
+
module Fishwife
|
29
|
+
require "#{LIB_DIR}/fishwife-#{VERSION}.jar"
|
30
|
+
end
|
31
|
+
|
26
32
|
require 'rack'
|
27
33
|
require 'fishwife/rack_servlet'
|
28
34
|
require 'fishwife/http_server'
|
data/lib/fishwife/base.rb
CHANGED
Binary file
|
@@ -15,6 +15,9 @@
|
|
15
15
|
# permissions and limitations under the License.
|
16
16
|
#++
|
17
17
|
|
18
|
+
# Magic loader hook -> JRubyService
|
19
|
+
require 'fishwife/JRuby'
|
20
|
+
|
18
21
|
#
|
19
22
|
# Wraps a Rack application in a Java servlet.
|
20
23
|
#
|
@@ -214,29 +217,20 @@ module Fishwife
|
|
214
217
|
end
|
215
218
|
end
|
216
219
|
|
217
|
-
# How else would we write output?
|
218
220
|
output = response.getOutputStream
|
219
221
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
#
|
225
|
-
|
226
|
-
|
227
|
-
#
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
# Stream the file directly.
|
232
|
-
buffer = Java::byte[4096].new
|
233
|
-
input_stream = FileInputStream.new(file)
|
234
|
-
while((count = input_stream.read(buffer)) != -1)
|
235
|
-
output.write(buffer, 0, count)
|
236
|
-
end
|
237
|
-
input_stream.close
|
222
|
+
if body.respond_to?( :to_path )
|
223
|
+
|
224
|
+
path = body.to_path
|
225
|
+
|
226
|
+
# Set Content-Length unless this is an async request.
|
227
|
+
response.setContentLength( File.size( path ) ) unless content_length
|
228
|
+
|
229
|
+
# FIXME: Support ranges?
|
230
|
+
|
231
|
+
OutputUtil.write_file( path, output )
|
238
232
|
else
|
239
|
-
|
233
|
+
OutputUtil.write_body( body, output )
|
240
234
|
end
|
241
235
|
|
242
236
|
# Close the body if we're supposed to.
|
data/pom.xml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
2
|
+
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
4
|
+
<groupId>fishwife</groupId>
|
5
|
+
<artifactId>fishwife</artifactId>
|
6
|
+
<packaging>jar</packaging>
|
7
|
+
<version>1.3.0</version>
|
8
|
+
<name>Fishwife Java Extension</name>
|
9
|
+
|
10
|
+
<properties>
|
11
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
12
|
+
</properties>
|
13
|
+
|
14
|
+
<dependencies>
|
15
|
+
|
16
|
+
<dependency>
|
17
|
+
<groupId>org.jruby.extras</groupId>
|
18
|
+
<artifactId>bytelist</artifactId>
|
19
|
+
<version>1.0.10</version>
|
20
|
+
<optional>true</optional>
|
21
|
+
</dependency>
|
22
|
+
|
23
|
+
<dependency>
|
24
|
+
<groupId>org.jruby</groupId>
|
25
|
+
<artifactId>jruby-core</artifactId>
|
26
|
+
<version>1.6.6</version>
|
27
|
+
<optional>true</optional>
|
28
|
+
</dependency>
|
29
|
+
|
30
|
+
</dependencies>
|
31
|
+
|
32
|
+
<build>
|
33
|
+
<plugins>
|
34
|
+
|
35
|
+
<plugin>
|
36
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
37
|
+
<version>2.3.2</version>
|
38
|
+
<configuration>
|
39
|
+
<source>1.6</source>
|
40
|
+
<target>1.6</target>
|
41
|
+
<optimize>true</optimize>
|
42
|
+
<debug>true</debug>
|
43
|
+
<encoding>UTF-8</encoding>
|
44
|
+
<showDeprecation>true</showDeprecation>
|
45
|
+
<showWarnings>true</showWarnings>
|
46
|
+
</configuration>
|
47
|
+
</plugin>
|
48
|
+
|
49
|
+
</plugins>
|
50
|
+
</build>
|
51
|
+
|
52
|
+
</project>
|
data/spec/fishwife_spec.rb
CHANGED
@@ -50,6 +50,7 @@ describe Fishwife do
|
|
50
50
|
|
51
51
|
after(:all) do
|
52
52
|
@server.stop
|
53
|
+
@server.join
|
53
54
|
end
|
54
55
|
|
55
56
|
it "returns 200 OK" do
|
@@ -134,8 +135,6 @@ describe Fishwife do
|
|
134
135
|
response = get("/download")
|
135
136
|
response.code.should == "200"
|
136
137
|
response['Content-Type'].should == 'image/png'
|
137
|
-
response['Content-Disposition'].should ==
|
138
|
-
'attachment; filename=reddit-icon.png'
|
139
138
|
checksum = Digest::MD5.hexdigest(response.body)
|
140
139
|
checksum.should == '8da4b60a9bbe205d4d3699985470627e'
|
141
140
|
end
|
@@ -161,6 +160,7 @@ describe Fishwife do
|
|
161
160
|
end
|
162
161
|
|
163
162
|
it "handles async requests" do
|
163
|
+
pending "Causes intermittent 30s pauses, TestApp.push/pull is sketchy"
|
164
164
|
lock = Mutex.new
|
165
165
|
buffer = Array.new
|
166
166
|
|
data/spec/spec_helper.rb
CHANGED
@@ -31,3 +31,20 @@ require 'rack/lint'
|
|
31
31
|
require 'fishwife'
|
32
32
|
|
33
33
|
Thread.abort_on_exception = true
|
34
|
+
|
35
|
+
# Adjust Rack::Lint to not interfere with File body.to_path
|
36
|
+
class Rack::Lint
|
37
|
+
|
38
|
+
def respond_to?( mth )
|
39
|
+
if mth == :to_path
|
40
|
+
@body.respond_to?( :to_path )
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_path
|
47
|
+
@body.to_path
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/spec/test_app.rb
CHANGED
@@ -104,12 +104,11 @@ class TestApp
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def download(request)
|
107
|
-
file = File.new(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
response.finish
|
107
|
+
file = File.new( File.dirname( __FILE__ ) + "/data/reddit-icon.png" )
|
108
|
+
def file.to_path
|
109
|
+
path
|
110
|
+
end
|
111
|
+
[ 200, { "Content-Type" => "image/png" }, file ]
|
113
112
|
end
|
114
113
|
|
115
114
|
def upload(request)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: fishwife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- David Kellum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.4.1
|
23
23
|
requirement: *id001
|
24
24
|
prerelease: false
|
25
25
|
type: :runtime
|
@@ -108,8 +108,10 @@ files:
|
|
108
108
|
- Manifest.txt
|
109
109
|
- README.rdoc
|
110
110
|
- Rakefile
|
111
|
+
- pom.xml
|
111
112
|
- bin/fishwife
|
112
113
|
- example/config.ru
|
114
|
+
- example/giant.ru
|
113
115
|
- lib/fishwife/base.rb
|
114
116
|
- lib/fishwife.rb
|
115
117
|
- lib/fishwife/http_server.rb
|
@@ -120,6 +122,7 @@ files:
|
|
120
122
|
- spec/test_app.rb
|
121
123
|
- spec/data/hello.txt
|
122
124
|
- spec/data/reddit-icon.png
|
125
|
+
- lib/fishwife/fishwife-1.3.0.jar
|
123
126
|
homepage: http://github.com/dekellum/fishwife
|
124
127
|
licenses: []
|
125
128
|
|