thick 0.0.8-java → 0.0.9-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68f8688da128a9ca14f1f2f60bf95a5122957462
4
- data.tar.gz: 864c08c83fe2016b2c897a2e8f57e372fd38a9d5
3
+ metadata.gz: 2e888a6f4de89327ea49ba352a44ea0c26dd4f1a
4
+ data.tar.gz: 6f7955f422fc51d1f95d26090a4a2b17fc19c31a
5
5
  SHA512:
6
- metadata.gz: 28d72f47efe4c073f6caf4fb7313606698c141a7d93d76791319cbdfbd9f3ac5bdc8ab3daa8479fc3aceb48e24216101dd0beb74ba8854114338aec7f39968f4
7
- data.tar.gz: 16c7d25a1ec19054110de9c6f2cba2eac8f6b9b3015271157c79bff98c8dcf4d33facf91315ed64f8ec5df55ad78061cf270520b7623d7f1e1e224e4196cd938
6
+ metadata.gz: 572e77ec80f7b73c18a61b3315b97f81a063221906c6326bdfcd8c8ad3aed4766ba81f6f2771a32942dcf87a6ecb92ac0fc84618c1b9cdbccf46e664297dba03
7
+ data.tar.gz: 5e4cd35f58d10aa4bcc6906a5def62a0539af8bb0b5509bd08df787ec09f73b06d311ca3c49c6610717f32385b347ffa3cf3e2cc0a3ee4115528e0adbd81c14d
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Portions copyright (c) 2012 Marek Jelen
1
+ Portions copyright (c) 2012-2016 Marek Jelen
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,124 +2,10 @@
2
2
 
3
3
  Thick is very lightweight web server for JRuby based on excellent Netty library.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/marekjelen/thick.png?branch=master)](http://travis-ci.org/marekjelen/thick)
6
-
7
5
  ## Status
8
6
 
9
7
  Works on several Sinatra and Rails applications. No real testing, yet.
10
8
 
11
- ## Speed
12
-
13
- see PERFORMANCE.md
14
-
15
- ## Interfaces
16
-
17
- Thick provides interfaces to control it's behaviour.
18
-
19
- ### WebSockets
20
-
21
- Thick allows to handle WebSocket in a simple and (IMHO) not intrusive way.
22
-
23
- When a request to WebSocket is received, the server send a PUT request to
24
-
25
- ```
26
- /thick/websockets
27
- ```
28
- and provides two keys in the environment
29
-
30
- ```ruby
31
- env['thick.websocket'].set_handler(Your::Handler)
32
- env['thick.websocket'].hand_shake("websocket URL")
33
- ```
34
-
35
- Your::Handler should subclass *Thick::WebSocket* class. It is used to provide interface
36
- between your application and the connection. The interface for communication from the
37
- client to your application looks like
38
-
39
- ```ruby
40
- class WebSocket < WebSocketHandler
41
-
42
- def on_open
43
- raise NotImplementedError.new("You should implement '#on_open' method.")
44
- end
45
-
46
- def on_data(data)
47
- raise NotImplementedError.new("You should implement '#on_data(data)' method.")
48
- end
49
-
50
- def on_close
51
- raise NotImplementedError.new("You should implement '#on_close' method.")
52
- end
53
-
54
- end
55
- ```
56
-
57
- Two more methods are available to control communicate back to the client
58
-
59
- ```ruby
60
- send("data") # sends data back to client
61
- close # closes the connection
62
- ```
63
-
64
- The *hand_shake("url")* method URL asks the server to finish the hand shake and upgrade
65
- the connection to WebSocket.
66
-
67
- ### Asynchronous responses
68
-
69
- Asynchronous responses provide functionality to stream response to the client by chunks.
70
-
71
- To enable streaming, run
72
-
73
- ```ruby
74
- env['thick.response'].chunked # For chunked encoded stream
75
- env['thick.response'].streamed # For raw stream
76
- ```
77
-
78
- and define "thick.async" callback in environment, so it reacts to "call" and takes one argument
79
-
80
- ```ruby
81
- env['thick.async'] = proc do |response|
82
- # do something here
83
- end
84
- ```
85
-
86
- now simply respond as usual. Once the headers and the basic content is sent, the callback will be invoked.
87
-
88
- To write content to the stream use
89
-
90
- ```ruby
91
- response.writeContent("some content")
92
- ```
93
-
94
- and do not forget close the stream once done
95
-
96
- ```ruby
97
- response.close
98
- ```
99
-
100
- Example using Sinatra
101
-
102
- ```ruby
103
- require 'sinatra/base'
104
-
105
- class App < Sinatra::Base
106
-
107
- get '/' do
108
- env['thick.async'] = proc do |response|
109
- (1..10).each do |i|
110
- response.writeContent(i.to_s)
111
- sleep(1)
112
- end
113
- response.close
114
- end
115
- env['thick.response'].chunked
116
- "0"
117
- end
118
-
119
- end
120
-
121
- run App
122
- ```
123
9
 
124
10
  ## Starting
125
11
 
data/bin/thick CHANGED
@@ -38,10 +38,6 @@ OptionParser.new do |opts|
38
38
  options[:environment] = e
39
39
  end
40
40
 
41
- opts.on('-C', '--controller', 'starts controller for remote monitoring and management') do |e|
42
- options[:controller] = e
43
- end
44
-
45
41
  end.parse!
46
42
 
47
- Thick.create(options)
43
+ Thick::Server.create(options)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -6,28 +6,13 @@ module Rack
6
6
  class Thick
7
7
 
8
8
  def self.run(app, options={})
9
-
10
- env = ::Thick::Java::ServerEnvironment.new
11
- env.address = options[:Host]
12
- env.port = options[:Port]
13
-
14
- env.application = ::Thick::Loader.new({:application => app, :environment => options[:environment]})
15
-
16
- server = ::Thick::Java::Server.new(env)
17
-
18
- Kernel.trap(:INT) { server.stop }
19
-
20
- server.start
21
-
9
+ options[:application] = app
10
+ server = ::Thick::Server.create(options)
22
11
  end
23
12
 
24
13
  end
25
14
 
26
15
  def self.valid_options
27
- {
28
- "Host=HOST" => "Hostname to listen on (default: localhost)",
29
- "Port=PORT" => "Port to listen on (default: 8080)"
30
- }
31
16
  end
32
17
 
33
18
  register 'thick', 'Rack::Handler::Thick'
data/lib/thick.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  require 'rack'
2
-
3
2
  require 'java'
4
3
 
5
- require File.expand_path('../jars/netty-4.0.0.Alpha8.jar', __FILE__)
6
- require File.expand_path('../jars/thick-0.0.1.jar', __FILE__)
4
+ $: << File.expand_path('..', __FILE__)
5
+
6
+ Dir[File.expand_path('../jar/*', __FILE__)].each { |path| require(path) }
7
7
 
8
- require 'thick/java'
9
8
  require 'thick/version'
10
- require 'thick/thick'
11
- require 'thick/loader'
12
- require 'thick/buffer'
13
- require 'thick/websocket'
9
+ require 'thick/server'
10
+
11
+ require 'rack/handler/thick'
@@ -0,0 +1,57 @@
1
+ require 'stringio'
2
+
3
+ module Thick
4
+
5
+ class RackAdapter < Java::CzWildwebRuby.RackAdapter
6
+
7
+ end
8
+
9
+ class Server
10
+
11
+ def self.create(options = {})
12
+ options = {
13
+ :address => '0.0.0.0',
14
+ :port => 9292,
15
+ :environment => 'development',
16
+ :directory => Dir.getwd,
17
+ :file => 'config.ru'
18
+ }.merge(options)
19
+
20
+ Thick::Server.new(options)
21
+ end
22
+
23
+ def initialize(options = {})
24
+ @options = options
25
+ ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] ||= @options[:environment]
26
+ if @options[:application]
27
+ @application = @options[:application]
28
+ else
29
+ @application ||= Rack::Builder.parse_file(File.expand_path(@options[:file], @options[:directory]))[0]
30
+ end
31
+
32
+ @application = Rack::Lint.new(@application)
33
+
34
+ @adapter = RackAdapter.new(@options[:address], @options[:port], '', false, JRuby.runtime, self)
35
+ @server = Java::CzWildwebServer::HttpServerImpl.new
36
+ @server.register('/', @adapter)
37
+ @server.register('/*', @adapter)
38
+ @server.start(@options[:address], @options[:port])
39
+ end
40
+
41
+ def call(env)
42
+ hash = {}
43
+ env.each_pair { |k,v| hash[k] = v }
44
+ hash['rack.version'] = [1,3]
45
+ hash['rack.input'] = StringIO.new(hash['rack.input'].force_encoding("ascii-8bit"))
46
+ hash['rack.errors'] = $stderr
47
+ puts hash.inspect
48
+ status, headers, content = @application.call(hash)
49
+ env['wildweb.response'].status(status)
50
+ headers.each_pair { |k,v| env['wildweb.response'].header(k.to_s, v.to_s) }
51
+ content.each { |data| env['wildweb.response'].write(data.to_s) }
52
+ env['wildweb.response'].close
53
+ end
54
+
55
+ end
56
+
57
+ end
data/lib/thick/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Thick
2
- VERSION = '0.0.8' unless const_defined?(:VERSION)
2
+ VERSION = '0.0.9' unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: java
6
6
  authors:
7
7
  - Marek Jelen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2016-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rack
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 1.5.2
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
- - - '='
16
+ - - "~>"
23
17
  - !ruby/object:Gem::Version
24
- version: 1.5.2
18
+ version: '1.6'
19
+ name: rack
25
20
  prerelease: false
26
21
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - '>='
24
+ - - "~>"
32
25
  - !ruby/object:Gem::Version
33
- version: '2'
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
- - - '>='
30
+ - - "~>"
37
31
  - !ruby/object:Gem::Version
38
32
  version: '2'
33
+ name: rspec
39
34
  prerelease: false
40
35
  type: :development
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - '>='
38
+ - - "~>"
46
39
  - !ruby/object:Gem::Version
47
- version: '10'
40
+ version: '2'
41
+ - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
- - - '>='
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
46
  version: '10'
47
+ name: rake
53
48
  prerelease: false
54
49
  type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
55
55
  description: Very lightweight web server for JRuby based on Netty library.
56
56
  email:
57
57
  - marek@jelen.biz
@@ -60,23 +60,28 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - LICENSE
64
+ - README.md
63
65
  - bin/thick
64
- - lib/thick.rb
66
+ - lib/jar/freemarker-2.3.23.jar
67
+ - lib/jar/javassist-3.20.0-GA.jar
68
+ - lib/jar/netty-buffer-4.1.0.CR3.jar
69
+ - lib/jar/netty-codec-4.1.0.CR3.jar
70
+ - lib/jar/netty-codec-http-4.1.0.CR3.jar
71
+ - lib/jar/netty-common-4.1.0.CR3.jar
72
+ - lib/jar/netty-handler-4.1.0.CR3.jar
73
+ - lib/jar/netty-resolver-4.1.0.CR3.jar
74
+ - lib/jar/netty-transport-4.1.0.CR3.jar
75
+ - lib/jar/slf4j-api-1.7.13.jar
76
+ - lib/jar/slf4j-simple-1.7.13.jar
77
+ - lib/jar/wildweb-0.0.1.jar
65
78
  - lib/rack/handler/thick.rb
66
- - lib/thick/thick.rb
67
- - lib/thick/java.rb
68
- - lib/thick/websocket.rb
69
- - lib/thick/loader.rb
70
- - lib/thick/buffer.rb
79
+ - lib/thick.rb
80
+ - lib/thick/server.rb
71
81
  - lib/thick/version.rb
72
- - lib/jars/netty-4.0.0.Alpha8.jar
73
- - lib/jars/thick-0.0.1.jar
74
- - LICENSE
75
- - README.md
76
- - ROADMAP.md
77
- - CHANGELOG.md
78
- homepage: http://github.com/marekjelen/thick
79
- licenses: []
82
+ homepage: http://github.com/marekjelen/wildweb
83
+ licenses:
84
+ - MIT
80
85
  metadata: {}
81
86
  post_install_message:
82
87
  rdoc_options: []
@@ -84,17 +89,17 @@ require_paths:
84
89
  - lib
85
90
  required_ruby_version: !ruby/object:Gem::Requirement
86
91
  requirements:
87
- - - '>='
92
+ - - ">="
88
93
  - !ruby/object:Gem::Version
89
94
  version: '0'
90
95
  required_rubygems_version: !ruby/object:Gem::Requirement
91
96
  requirements:
92
- - - '>='
97
+ - - ">="
93
98
  - !ruby/object:Gem::Version
94
99
  version: '0'
95
100
  requirements: []
96
101
  rubyforge_project:
97
- rubygems_version: 2.1.9
102
+ rubygems_version: 2.4.8
98
103
  signing_key:
99
104
  specification_version: 4
100
105
  summary: Very lightweight web server for JRuby
data/CHANGELOG.md DELETED
@@ -1,39 +0,0 @@
1
- ## 0.0.8 (XY.01.2013)
2
-
3
- * Rack handler
4
- * update versions in CHANGELOG
5
-
6
- ## 0.0.7 (20.12.2012)
7
-
8
- * update Netty to 4th version
9
- * support for WebSockets
10
- * new buffer for uploaded data
11
- * simpler interface for async responses
12
-
13
- ## 0.0.6 (01.12.2012)
14
-
15
- * some weird version
16
-
17
- ## 0.0.5 (30.11.2012)
18
-
19
- * update Netty to 3.5.11
20
- * get rid of Loader experiment
21
- * update Rake gem (development)
22
-
23
- ## 0.0.4 (29.3.2012)
24
-
25
- * make gem Java specific
26
- * copy-less request body container
27
- * async responses
28
-
29
- ## 0.0.3 (26.3.2012)
30
-
31
- Update Netty to 3.4.0.Alpha2
32
-
33
- ## 0.0.2 (26.3.2012)
34
-
35
- First public version
36
-
37
- ## 0.0.1 (26.3.2012)
38
-
39
- Claim the gem ;)
data/ROADMAP.md DELETED
@@ -1,11 +0,0 @@
1
- ## Must to have
2
-
3
- * SSL support
4
- * Tests
5
- * Code refactorings
6
- * Optimizations
7
- * Keep-alive
8
-
9
- ## Nice to have
10
-
11
- * SPDY support
Binary file
Binary file
data/lib/thick/buffer.rb DELETED
@@ -1,47 +0,0 @@
1
- module Thick
2
-
3
- class Buffer
4
-
5
- java_import "io.netty.buffer.ByteBuf"
6
- java_import "io.netty.buffer.Unpooled"
7
-
8
- def initialize(buffer=nil)
9
- @buffer = buffer || Unpooled.buffer
10
- end
11
-
12
- def write(buffer)
13
- raise ArgumentError.new('ByteBuf is expected') unless buffer.kind_of?(ByteBuf)
14
- @buffer.writeBytes(buffer)
15
- end
16
-
17
- def rewind
18
- @buffer.reset_reader_index
19
- end
20
-
21
- def read(n=nil, buffer=nil)
22
- return n ? nil : '' unless @buffer.readable
23
- buffer ||= ""
24
- n ||= @buffer.readable_bytes
25
- buffer << java.lang.String.new(@buffer.read_bytes(n).array).to_s
26
- end
27
-
28
- def each(&block)
29
- while (data = gets)
30
- block.call( data || "")
31
- end
32
- end
33
-
34
- def gets
35
- return nil unless @buffer.readable
36
- nl = @buffer.bytes_before(10)
37
- if nl == -1
38
- nl = @buffer.readable_bytes
39
- else
40
- nl += 1
41
- end
42
- read(nl)
43
- end
44
-
45
- end
46
-
47
- end
data/lib/thick/java.rb DELETED
@@ -1,10 +0,0 @@
1
- module Thick
2
- module Java
3
-
4
- java_import 'cz.marekjelen.thick.Server'
5
- java_import 'cz.marekjelen.thick.ServerEnvironment'
6
- java_import 'cz.marekjelen.thick.ServerRubyInterface'
7
- java_import 'io.netty.buffer.Unpooled'
8
- java_import 'io.netty.buffer.ByteBufInputStream'
9
- end
10
- end
data/lib/thick/loader.rb DELETED
@@ -1,48 +0,0 @@
1
- module Thick
2
-
3
- class Loader
4
-
5
- include Thick::Java::ServerRubyInterface
6
-
7
- def initialize(options)
8
- @options = options
9
- ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] ||= @options[:environment]
10
- @application = @options[:application] ||= Rack::Builder.parse_file(File.expand_path(@options[:file], @options[:directory]))[0]
11
- end
12
-
13
- def call(env)
14
- env['rack.input'] = Buffer.new(env['rack.input'])
15
- env['rack.errors'] = env['rack.errors'].to_io
16
-
17
- status, headers, body = @application.call(env)
18
-
19
- return if env['thick.response_bypass']
20
-
21
- response = env['thick.response']
22
-
23
- response.setStatus(status)
24
-
25
- hijack = headers.delete('rack.hijack')
26
-
27
- headers.each_pair do |name, value|
28
- response.setHeader(name, value)
29
- end
30
-
31
- if body.respond_to?(:to_path)
32
- response.send_file(body.to_path)
33
- else
34
- body.each { |chunk| response.writeContent(chunk.to_s) }
35
- response.send
36
- # Rack Hijack async response
37
- hijack.call(env['rack.hijakck_io']) if hijack
38
- # Thick native async response
39
- env['thick.async'].call(response) if response.chunked?
40
- end
41
- rescue => e
42
- puts e.message
43
- puts e.backtrace
44
- end
45
-
46
- end
47
-
48
- end
data/lib/thick/thick.rb DELETED
@@ -1,25 +0,0 @@
1
- module Thick
2
-
3
- def self.create(options)
4
-
5
- options = {
6
- :address => '0.0.0.0',
7
- :port => 9292,
8
- :environment => 'development',
9
- :directory => Dir.getwd,
10
- :file => 'config.ru'
11
- }.merge(options)
12
-
13
- puts "* Starting Thick: #{options.inspect}"
14
-
15
- env = Thick::Java::ServerEnvironment.new
16
- env.address = options[:address]
17
- env.port = options[:port]
18
-
19
- env.application = Loader.new(options)
20
-
21
- Thick::Java::Server.new(env).start
22
-
23
- end
24
-
25
- end
@@ -1,21 +0,0 @@
1
- module Thick
2
-
3
- java_import 'cz.marekjelen.thick.WebSocketHandler'
4
-
5
- class WebSocket < WebSocketHandler
6
-
7
- def on_open
8
- raise NotImplementedError.new("You should implement '#on_open' method.")
9
- end
10
-
11
- def on_data(data)
12
- raise NotImplementedError.new("You should implement '#on_data(data)' method.")
13
- end
14
-
15
- def on_close
16
- raise NotImplementedError.new("You should implement '#on_close' method.")
17
- end
18
-
19
- end
20
-
21
- end