tubesock 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tubesock/version.rb +1 -1
- data/lib/tubesock.rb +20 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a96bee3c54c81518af3d9105a737f23f78f5b76
|
4
|
+
data.tar.gz: 1d96fd26516fd0244f2d9ef625466a96b08008f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 260ad5ab303a82b4aac2c9c4d66a27a5c4f33520d54a03f73368fb2bf2dfff2910fc281577d1b98c58522f5fb9da8fbf49576c15221fe7374fbf5d2bb7c04074
|
7
|
+
data.tar.gz: 163b2d57d72292578a13b6e38084390a5c1b1545fce0d45ea3856de790350281fa2c3efe4cd5b558c26776ae27d92bcd307d4b1c65448668618d5201cbfdadf5
|
data/lib/tubesock/version.rb
CHANGED
data/lib/tubesock.rb
CHANGED
@@ -2,28 +2,35 @@ require "tubesock/version"
|
|
2
2
|
require "tubesock/hijack" if defined?(Rails)
|
3
3
|
|
4
4
|
class Tubesock
|
5
|
+
class HijackNotAvailable < RuntimeError
|
6
|
+
end
|
7
|
+
|
5
8
|
def initialize(socket, version)
|
6
9
|
@socket = socket
|
7
10
|
@version = version
|
8
11
|
end
|
9
12
|
|
10
13
|
def self.hijack(env)
|
11
|
-
env['rack.hijack']
|
12
|
-
|
14
|
+
if env['rack.hijack']
|
15
|
+
env['rack.hijack'].call
|
16
|
+
socket = env['rack.hijack_io']
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
handshake = WebSocket::Handshake::Server.new
|
19
|
+
handshake.headers["sec-websocket-version"] = env["HTTP_SEC_WEBSOCKET_VERSION"]
|
20
|
+
handshake.headers["sec-websocket-draft"] = env["HTTP_SEC_WEBSOCKET_DRAFT"]
|
21
|
+
handshake.headers["sec-websocket-key"] = env["HTTP_SEC_WEBSOCKET_KEY"]
|
22
|
+
handshake.headers["sec-websocket-extensions"] = env["HTTP_SEC_WEBSOCKET_EXTENSIONS"]
|
23
|
+
handshake.headers["host"] = env["HTTP_HOST"]
|
24
|
+
handshake.path = env["REQUEST_PATH"]
|
25
|
+
handshake.query = env["QUERY_STRING"]
|
26
|
+
handshake.set_version
|
23
27
|
|
24
|
-
|
28
|
+
socket.write handshake.to_s
|
25
29
|
|
26
|
-
|
30
|
+
self.new socket, handshake.version
|
31
|
+
else
|
32
|
+
raise Tubesock::HijackNotAvailable
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
def self.websocket?(env)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tubesock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|