jruby-http-kit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +1 -1
- data/lib/http_kit/version.rb +1 -1
- data/lib/java/http-kit.jar +0 -0
- data/lib/webmachine/adapters/ring.rb +112 -46
- data/src/org/httpkit/HttpUtils.java +1 -3
- metadata +2 -66
- data/src/org/httpkit/BytesInputStream.class +0 -0
- data/src/org/httpkit/DateFormatter.class +0 -0
- data/src/org/httpkit/DynamicBytes.class +0 -0
- data/src/org/httpkit/HTTPException.class +0 -0
- data/src/org/httpkit/HeaderMap.class +0 -0
- data/src/org/httpkit/HttpMethod.class +0 -0
- data/src/org/httpkit/HttpStatus.class +0 -0
- data/src/org/httpkit/HttpUtils.class +0 -0
- data/src/org/httpkit/HttpVersion.class +0 -0
- data/src/org/httpkit/LineReader.class +0 -0
- data/src/org/httpkit/LineTooLargeException.class +0 -0
- data/src/org/httpkit/PrefixThreadFactory.class +0 -0
- data/src/org/httpkit/PriorityQueue.class +0 -0
- data/src/org/httpkit/ProtocolException.class +0 -0
- data/src/org/httpkit/RequestTooLargeException.class +0 -0
- data/src/org/httpkit/client/AbortException.class +0 -0
- data/src/org/httpkit/client/Decoder.class +0 -0
- data/src/org/httpkit/client/Handler.class +0 -0
- data/src/org/httpkit/client/HttpClient.class +0 -0
- data/src/org/httpkit/client/HttpsRequest.class +0 -0
- data/src/org/httpkit/client/IFilter$1.class +0 -0
- data/src/org/httpkit/client/IFilter$MaxBodyFilter.class +0 -0
- data/src/org/httpkit/client/IFilter.class +0 -0
- data/src/org/httpkit/client/IRespListener.class +0 -0
- data/src/org/httpkit/client/IResponseHandler.class +0 -0
- data/src/org/httpkit/client/PersistentConn.class +0 -0
- data/src/org/httpkit/client/Request.class +0 -0
- data/src/org/httpkit/client/RequestConfig.class +0 -0
- data/src/org/httpkit/client/RespListener.class +0 -0
- data/src/org/httpkit/client/SslContextFactory.class +0 -0
- data/src/org/httpkit/client/State.class +0 -0
- data/src/org/httpkit/client/TimeoutException.class +0 -0
- data/src/org/httpkit/client/TrustManagerFactory$1.class +0 -0
- data/src/org/httpkit/client/TrustManagerFactory.class +0 -0
- data/src/org/httpkit/server/AsyncChannel.class +0 -0
- data/src/org/httpkit/server/ClojureRing.class +0 -0
- data/src/org/httpkit/server/Frame$BinaryFrame.class +0 -0
- data/src/org/httpkit/server/Frame$CloseFrame.class +0 -0
- data/src/org/httpkit/server/Frame$PingFrame.class +0 -0
- data/src/org/httpkit/server/Frame$TextFrame.class +0 -0
- data/src/org/httpkit/server/Frame.class +0 -0
- data/src/org/httpkit/server/HttpAtta.class +0 -0
- data/src/org/httpkit/server/HttpDecoder$State.class +0 -0
- data/src/org/httpkit/server/HttpDecoder.class +0 -0
- data/src/org/httpkit/server/HttpHandler.class +0 -0
- data/src/org/httpkit/server/HttpRequest.class +0 -0
- data/src/org/httpkit/server/HttpServer.class +0 -0
- data/src/org/httpkit/server/IHandler.class +0 -0
- data/src/org/httpkit/server/LinkingRunnable.class +0 -0
- data/src/org/httpkit/server/Rack.class +0 -0
- data/src/org/httpkit/server/RackApplication.class +0 -0
- data/src/org/httpkit/server/RackHandler$1.class +0 -0
- data/src/org/httpkit/server/RackHandler.class +0 -0
- data/src/org/httpkit/server/RackHttpHandler.class +0 -0
- data/src/org/httpkit/server/RespCallback.class +0 -0
- data/src/org/httpkit/server/RingHandler$1.class +0 -0
- data/src/org/httpkit/server/RingHandler.class +0 -0
- data/src/org/httpkit/server/ServerAtta.class +0 -0
- data/src/org/httpkit/server/WSDecoder$State.class +0 -0
- data/src/org/httpkit/server/WSDecoder.class +0 -0
- data/src/org/httpkit/server/WSHandler.class +0 -0
- data/src/org/httpkit/server/WsAtta.class +0 -0
- data/src/org/httpkit/timer/CancelableFutureTask.class +0 -0
- data/src/org/httpkit/timer/TimerService.class +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0ee1cfec6c0b083e4e14f40c19c3f1e08de3deb
|
4
|
+
data.tar.gz: 54fd5b14b11c88f35ed72fef3accc1bca81acd3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ce94806602644409650c87de9285893a8e8870596f7f2dfc0d08f73dfa2a70c4fcf8a3661f7af7d7d1e219ef38bd8275be4719417a2d773aa527605b3400ce
|
7
|
+
data.tar.gz: 86774b516625bf565cedc38f137f449331cbd1c3b937b58bfb9abf977630178ab88e0bccee115356f2310427dce2ba474dcf42cfacceaeb66f00ebd97c59edcb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/lib/http_kit/version.rb
CHANGED
data/lib/java/http-kit.jar
CHANGED
Binary file
|
@@ -1,12 +1,33 @@
|
|
1
|
+
require 'webmachine/adapter'
|
2
|
+
require 'webmachine/chunked_body'
|
3
|
+
|
1
4
|
module Webmachine
|
2
5
|
module Adapters
|
3
6
|
class Ring < Webmachine::Adapter
|
4
7
|
|
8
|
+
java_import Java::JavaNio::ByteBuffer
|
9
|
+
|
10
|
+
java_import Java::ClojureLang::Keyword
|
11
|
+
java_import Java::ClojureLang::PersistentHashMap
|
12
|
+
|
13
|
+
java_import Java::OrgHttpkit::DynamicBytes
|
14
|
+
java_import Java::OrgHttpkit::HttpUtils
|
15
|
+
java_import Java::OrgHttpkitServer::RingHandler
|
16
|
+
java_import Java::OrgHttpkitServer::HttpServer
|
17
|
+
|
18
|
+
|
19
|
+
STATUS = Keyword.intern("status")
|
20
|
+
HEADERS = Keyword.intern("headers")
|
21
|
+
BODY = Keyword.intern("body")
|
22
|
+
REQUEST_URI = Keyword.intern("uri")
|
23
|
+
QUERY_STRING = Keyword.intern("query-string")
|
24
|
+
METHOD = Keyword.intern("request-method")
|
25
|
+
|
5
26
|
DEFAULT_OPTIONS = {
|
6
|
-
:port
|
7
|
-
:host
|
8
|
-
:threads
|
9
|
-
:queue_size
|
27
|
+
:port => 9292,
|
28
|
+
:host => "0.0.0.0",
|
29
|
+
:threads => 50,
|
30
|
+
:queue_size => 1000,
|
10
31
|
:worker_prefix => "wm-",
|
11
32
|
:max_body_size => 8388608,
|
12
33
|
:max_http_line => 4096
|
@@ -21,16 +42,16 @@ module Webmachine
|
|
21
42
|
|
22
43
|
req_handler = Handler.new(dispatcher)
|
23
44
|
|
24
|
-
@ring_handler =
|
25
|
-
|
26
|
-
|
27
|
-
|
45
|
+
@ring_handler = RingHandler.new(options[:threads],
|
46
|
+
req_handler,
|
47
|
+
options[:worker_prefix],
|
48
|
+
options[:queue_size])
|
28
49
|
|
29
|
-
@server =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
50
|
+
@server = HttpServer.new(options[:host],
|
51
|
+
options[:port].to_i,
|
52
|
+
@ring_handler,
|
53
|
+
options[:max_body_size],
|
54
|
+
options[:max_http_line])
|
34
55
|
|
35
56
|
@server.start()
|
36
57
|
|
@@ -67,9 +88,7 @@ module Webmachine
|
|
67
88
|
|
68
89
|
dispatcher.dispatch(request, response)
|
69
90
|
|
70
|
-
|
71
|
-
|
72
|
-
Ring::RingResponse.create(response.code, headers, response.body)
|
91
|
+
Ring::RingResponse.from_webmachine(response)
|
73
92
|
end
|
74
93
|
end
|
75
94
|
|
@@ -79,54 +98,101 @@ module Webmachine
|
|
79
98
|
end
|
80
99
|
|
81
100
|
def headers
|
82
|
-
|
101
|
+
ruby_headers = {}
|
102
|
+
|
103
|
+
ring_headers = @request.get(Ring::HEADERS)
|
104
|
+
ring_headers.iterator().each do |h|
|
105
|
+
ruby_headers[h[0]] = h[1]
|
106
|
+
end
|
107
|
+
|
108
|
+
Webmachine::Headers[ruby_headers]
|
83
109
|
end
|
84
110
|
|
85
111
|
def body
|
86
|
-
_body = @request.get(
|
87
|
-
_body
|
112
|
+
_body = @request.get( Ring::BODY )
|
113
|
+
RingRequest::Body.new(_body.to_io) if _body
|
88
114
|
end
|
89
115
|
|
90
116
|
def url
|
91
|
-
uri = @request.get(
|
92
|
-
query_string = @request.get(
|
93
|
-
|
94
|
-
URI.parse(
|
117
|
+
uri = @request.get(Ring::REQUEST_URI)
|
118
|
+
query_string = @request.get(Ring::QUERY_STRING)
|
119
|
+
uri << "?#{query_string}" if query_string && query_string != ""
|
120
|
+
URI.parse(uri)
|
95
121
|
end
|
96
122
|
|
97
123
|
def method
|
98
|
-
@request.get(
|
124
|
+
@request.get(Ring::METHOD).to_s.delete(':').upcase
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class RingRequest::Body
|
129
|
+
def initialize(body)
|
130
|
+
@body = body
|
99
131
|
end
|
100
132
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
# m.put(REQUEST_METHOD, req.method.KEY);
|
110
|
-
|
111
|
-
# // key is already lower cased, required by ring spec
|
112
|
-
# m.put(HEADERS, PersistentArrayMap.create(req.headers));
|
113
|
-
# m.put(CONTENT_TYPE, req.contentType);
|
114
|
-
# m.put(CONTENT_LENGTH, req.contentLength);
|
115
|
-
# m.put(CHARACTER_ENCODING, req.charset);
|
116
|
-
# m.put(BODY, req.getBody());
|
117
|
-
# return PersistentArrayMap.create(m);
|
133
|
+
def to_s
|
134
|
+
if @value
|
135
|
+
@value.join
|
136
|
+
else
|
137
|
+
@body.rewind
|
138
|
+
@body.read
|
139
|
+
end
|
140
|
+
end
|
118
141
|
|
142
|
+
def each
|
143
|
+
if @value
|
144
|
+
@value.each {|chunk| yield chunk }
|
145
|
+
else
|
146
|
+
@value = []
|
147
|
+
@body.each {|chunk| @value << chunk; yield chunk }
|
148
|
+
end
|
149
|
+
end
|
119
150
|
end
|
120
151
|
|
121
152
|
class RingResponse
|
122
|
-
def self.
|
153
|
+
def self.from_webmachine(response)
|
154
|
+
headers = response.headers
|
155
|
+
|
156
|
+
# HTTP-Kit sets its own Content-Length
|
157
|
+
headers.delete("Content-Length")
|
158
|
+
|
159
|
+
headers.each do |k, v|
|
160
|
+
headers[k] = v.join(", ") if v.is_a? Array
|
161
|
+
end
|
162
|
+
|
163
|
+
response_body = if response.body.respond_to?(:call)
|
164
|
+
Webmachine::ChunkedBody.new([response.body.call])
|
165
|
+
elsif response.body.respond_to?(:each)
|
166
|
+
# This might be an IOEncoder with a Content-Length, which shouldn't be chunked.
|
167
|
+
if response.headers["Transfer-Encoding"] == "chunked"
|
168
|
+
Webmachine::ChunkedBody.new(response.body)
|
169
|
+
else
|
170
|
+
response.body
|
171
|
+
end
|
172
|
+
elsif response.body.is_a? IO
|
173
|
+
response.body.to_outputstream
|
174
|
+
else
|
175
|
+
response.body
|
176
|
+
end
|
177
|
+
|
178
|
+
if response_body.respond_to?(:each)
|
179
|
+
ring_body = ""
|
180
|
+
response_body.each do |chunk|
|
181
|
+
ring_body << chunk.to_s
|
182
|
+
end
|
183
|
+
else
|
184
|
+
ring_body = response_body
|
185
|
+
end
|
186
|
+
|
187
|
+
headers = Java::JavaUtil::HashMap.new(headers)
|
188
|
+
|
123
189
|
ring_response = [
|
124
|
-
|
125
|
-
|
126
|
-
|
190
|
+
Ring::STATUS , response.code,
|
191
|
+
Ring::HEADERS , headers,
|
192
|
+
Ring::BODY , ring_body
|
127
193
|
]
|
128
194
|
|
129
|
-
return
|
195
|
+
return PersistentHashMap.create(ring_response.to_java)
|
130
196
|
end
|
131
197
|
end
|
132
198
|
|
@@ -431,9 +431,7 @@ public class HttpUtils {
|
|
431
431
|
if (!CHUNKED.equals(headers.get("Transfer-Encoding"))) {
|
432
432
|
if (bodyBuffer != null) {
|
433
433
|
headers.put(CL, Integer.toString(bodyBuffer.remaining()));
|
434
|
-
}
|
435
|
-
headers.put(CL, "0");
|
436
|
-
}
|
434
|
+
}
|
437
435
|
}
|
438
436
|
} catch (IOException e) {
|
439
437
|
byte[] b = e.getMessage().getBytes(ASCII);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby-http-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Rozhkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,113 +103,49 @@ files:
|
|
103
103
|
- spec/webmachine/ring_adapter_spec.rb
|
104
104
|
- src/.classpath
|
105
105
|
- src/.project
|
106
|
-
- src/org/httpkit/BytesInputStream.class
|
107
106
|
- src/org/httpkit/BytesInputStream.java
|
108
|
-
- src/org/httpkit/DateFormatter.class
|
109
|
-
- src/org/httpkit/DynamicBytes.class
|
110
107
|
- src/org/httpkit/DynamicBytes.java
|
111
|
-
- src/org/httpkit/HTTPException.class
|
112
108
|
- src/org/httpkit/HTTPException.java
|
113
|
-
- src/org/httpkit/HeaderMap.class
|
114
109
|
- src/org/httpkit/HeaderMap.java
|
115
|
-
- src/org/httpkit/HttpMethod.class
|
116
110
|
- src/org/httpkit/HttpMethod.java
|
117
|
-
- src/org/httpkit/HttpStatus.class
|
118
111
|
- src/org/httpkit/HttpStatus.java
|
119
|
-
- src/org/httpkit/HttpUtils.class
|
120
112
|
- src/org/httpkit/HttpUtils.java
|
121
|
-
- src/org/httpkit/HttpVersion.class
|
122
113
|
- src/org/httpkit/HttpVersion.java
|
123
|
-
- src/org/httpkit/LineReader.class
|
124
114
|
- src/org/httpkit/LineReader.java
|
125
|
-
- src/org/httpkit/LineTooLargeException.class
|
126
115
|
- src/org/httpkit/LineTooLargeException.java
|
127
|
-
- src/org/httpkit/PrefixThreadFactory.class
|
128
116
|
- src/org/httpkit/PrefixThreadFactory.java
|
129
|
-
- src/org/httpkit/PriorityQueue.class
|
130
117
|
- src/org/httpkit/PriorityQueue.java
|
131
|
-
- src/org/httpkit/ProtocolException.class
|
132
118
|
- src/org/httpkit/ProtocolException.java
|
133
|
-
- src/org/httpkit/RequestTooLargeException.class
|
134
119
|
- src/org/httpkit/RequestTooLargeException.java
|
135
|
-
- src/org/httpkit/client/AbortException.class
|
136
120
|
- src/org/httpkit/client/AbortException.java
|
137
|
-
- src/org/httpkit/client/Decoder.class
|
138
121
|
- src/org/httpkit/client/Decoder.java
|
139
|
-
- src/org/httpkit/client/Handler.class
|
140
|
-
- src/org/httpkit/client/HttpClient.class
|
141
122
|
- src/org/httpkit/client/HttpClient.java
|
142
|
-
- src/org/httpkit/client/HttpsRequest.class
|
143
123
|
- src/org/httpkit/client/HttpsRequest.java
|
144
|
-
- src/org/httpkit/client/IFilter$1.class
|
145
|
-
- src/org/httpkit/client/IFilter$MaxBodyFilter.class
|
146
|
-
- src/org/httpkit/client/IFilter.class
|
147
124
|
- src/org/httpkit/client/IFilter.java
|
148
|
-
- src/org/httpkit/client/IRespListener.class
|
149
125
|
- src/org/httpkit/client/IRespListener.java
|
150
|
-
- src/org/httpkit/client/IResponseHandler.class
|
151
126
|
- src/org/httpkit/client/IResponseHandler.java
|
152
|
-
- src/org/httpkit/client/PersistentConn.class
|
153
127
|
- src/org/httpkit/client/PersistentConn.java
|
154
|
-
- src/org/httpkit/client/Request.class
|
155
128
|
- src/org/httpkit/client/Request.java
|
156
|
-
- src/org/httpkit/client/RequestConfig.class
|
157
129
|
- src/org/httpkit/client/RequestConfig.java
|
158
|
-
- src/org/httpkit/client/RespListener.class
|
159
130
|
- src/org/httpkit/client/RespListener.java
|
160
|
-
- src/org/httpkit/client/SslContextFactory.class
|
161
131
|
- src/org/httpkit/client/SslContextFactory.java
|
162
|
-
- src/org/httpkit/client/State.class
|
163
|
-
- src/org/httpkit/client/TimeoutException.class
|
164
132
|
- src/org/httpkit/client/TimeoutException.java
|
165
|
-
- src/org/httpkit/client/TrustManagerFactory$1.class
|
166
|
-
- src/org/httpkit/client/TrustManagerFactory.class
|
167
|
-
- src/org/httpkit/server/AsyncChannel.class
|
168
133
|
- src/org/httpkit/server/AsyncChannel.java
|
169
|
-
- src/org/httpkit/server/ClojureRing.class
|
170
|
-
- src/org/httpkit/server/Frame$BinaryFrame.class
|
171
|
-
- src/org/httpkit/server/Frame$CloseFrame.class
|
172
|
-
- src/org/httpkit/server/Frame$PingFrame.class
|
173
|
-
- src/org/httpkit/server/Frame$TextFrame.class
|
174
|
-
- src/org/httpkit/server/Frame.class
|
175
134
|
- src/org/httpkit/server/Frame.java
|
176
|
-
- src/org/httpkit/server/HttpAtta.class
|
177
135
|
- src/org/httpkit/server/HttpAtta.java
|
178
|
-
- src/org/httpkit/server/HttpDecoder$State.class
|
179
|
-
- src/org/httpkit/server/HttpDecoder.class
|
180
136
|
- src/org/httpkit/server/HttpDecoder.java
|
181
|
-
- src/org/httpkit/server/HttpHandler.class
|
182
|
-
- src/org/httpkit/server/HttpRequest.class
|
183
137
|
- src/org/httpkit/server/HttpRequest.java
|
184
|
-
- src/org/httpkit/server/HttpServer.class
|
185
138
|
- src/org/httpkit/server/HttpServer.java
|
186
|
-
- src/org/httpkit/server/IHandler.class
|
187
139
|
- src/org/httpkit/server/IHandler.java
|
188
|
-
- src/org/httpkit/server/LinkingRunnable.class
|
189
|
-
- src/org/httpkit/server/Rack.class
|
190
|
-
- src/org/httpkit/server/RackApplication.class
|
191
140
|
- src/org/httpkit/server/RackApplication.java
|
192
|
-
- src/org/httpkit/server/RackHandler$1.class
|
193
|
-
- src/org/httpkit/server/RackHandler.class
|
194
141
|
- src/org/httpkit/server/RackHandler.java
|
195
|
-
- src/org/httpkit/server/RackHttpHandler.class
|
196
142
|
- src/org/httpkit/server/RackHttpHandler.java
|
197
|
-
- src/org/httpkit/server/RespCallback.class
|
198
143
|
- src/org/httpkit/server/RespCallback.java
|
199
|
-
- src/org/httpkit/server/RingHandler$1.class
|
200
|
-
- src/org/httpkit/server/RingHandler.class
|
201
144
|
- src/org/httpkit/server/RingHandler.java
|
202
|
-
- src/org/httpkit/server/ServerAtta.class
|
203
145
|
- src/org/httpkit/server/ServerAtta.java
|
204
|
-
- src/org/httpkit/server/WSDecoder$State.class
|
205
|
-
- src/org/httpkit/server/WSDecoder.class
|
206
146
|
- src/org/httpkit/server/WSDecoder.java
|
207
|
-
- src/org/httpkit/server/WSHandler.class
|
208
|
-
- src/org/httpkit/server/WsAtta.class
|
209
147
|
- src/org/httpkit/server/WsAtta.java
|
210
|
-
- src/org/httpkit/timer/CancelableFutureTask.class
|
211
148
|
- src/org/httpkit/timer/CancelableFutureTask.java
|
212
|
-
- src/org/httpkit/timer/TimerService.class
|
213
149
|
- src/org/httpkit/timer/TimerService.java
|
214
150
|
homepage: https://github.com/nLight/jruby-http-kit
|
215
151
|
licenses:
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|