hessian2 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -10
- data/README.md +197 -197
- data/hessian2.gemspec +0 -2
- data/lib/hessian2/client.rb +57 -50
- data/lib/hessian2/constants.rb +164 -164
- data/lib/hessian2/fault.rb +3 -3
- data/lib/hessian2/handler.rb +18 -18
- data/lib/hessian2/hessian_client.rb +3 -3
- data/lib/hessian2/parser.rb +619 -619
- data/lib/hessian2/type_wrapper.rb +49 -49
- data/lib/hessian2/version.rb +3 -3
- data/lib/hessian2/writer.rb +499 -499
- data/lib/hessian2.rb +14 -14
- data/spec/binary_spec.rb +51 -51
- data/spec/boolean_spec.rb +26 -26
- data/spec/class_wrapper_spec.rb +52 -52
- data/spec/create_monkeys.rb +14 -14
- data/spec/date_spec.rb +45 -45
- data/spec/double_spec.rb +78 -78
- data/spec/int_spec.rb +54 -54
- data/spec/list_spec.rb +66 -66
- data/spec/long_spec.rb +68 -68
- data/spec/map_spec.rb +36 -36
- data/spec/null_spec.rb +17 -17
- data/spec/object_spec.rb +78 -78
- data/spec/ref_spec.rb +43 -43
- data/spec/spec_helper.rb +23 -23
- data/spec/string_spec.rb +61 -61
- data/spec/struct_wrapper_spec.rb +47 -47
- data/spec/type_wrapper_spec.rb +102 -102
- data/test/app.rb +24 -24
- data/test/async/em_http_asleep.rb +25 -25
- data/test/async/em_http_sleep.rb +25 -25
- data/test/async/monkey.asleep.rb +27 -27
- data/test/async/mysql2_aquery.rb +37 -37
- data/test/fault/monkey.undefined_method.rb +5 -5
- data/test/fault/monkey.wrong_arguments.rb +5 -5
- data/test/fiber_concurrency/em_http_asleep.rb +17 -17
- data/test/fiber_concurrency/em_http_sleep.rb +17 -17
- data/test/fiber_concurrency/monkey.asleep.fiber_aware.rb +18 -18
- data/test/fiber_concurrency/mysql2_query.rb +29 -29
- data/test/fiber_concurrency/net_http_asleep.rb +19 -19
- data/test/fiber_concurrency/net_http_sleep.rb +19 -19
- data/test/fibered_rainbows/Gemfile +15 -15
- data/test/fibered_rainbows/config.ru +11 -11
- data/test/fibered_rainbows/rainbows.rb +13 -13
- data/test/monkey_service.rb +16 -16
- data/test/prepare.rb +7 -7
- data/test/thread_concurrency/active_record_execute.rb +29 -29
- data/test/thread_concurrency/monkey.asleep.rb +22 -22
- data/test/thread_concurrency/net_http_asleep.rb +24 -24
- data/test/thread_concurrency/net_http_sleep.rb +24 -24
- data/test/threaded_rainbows/Gemfile +13 -13
- data/test/threaded_rainbows/config.ru +9 -9
- data/test/threaded_rainbows/rainbows.rb +13 -13
- metadata +4 -74
data/lib/hessian2/constants.rb
CHANGED
@@ -1,164 +1,164 @@
|
|
1
|
-
module Hessian2
|
2
|
-
#=== Hessian 2.0 Web Services Protocol Bytecode map
|
3
|
-
#
|
4
|
-
# x00 - x42 # reserved
|
5
|
-
# x43 # rpc call ('C')
|
6
|
-
# x44 # reserved
|
7
|
-
# x45 # envelope ('E')
|
8
|
-
# x46 # fault ('F')
|
9
|
-
# x47 # reserved
|
10
|
-
# x48 # hessian version ('H')
|
11
|
-
# x49 - x4f # reserved
|
12
|
-
# x4f # packet chunk ('O')
|
13
|
-
# x50 # packet end ('P')
|
14
|
-
# x51 # reserved
|
15
|
-
# x52 # rpc result ('R')
|
16
|
-
# x53 - x59 # reserved
|
17
|
-
# x5a # terminator ('Z')
|
18
|
-
# x5b - x5f # reserved
|
19
|
-
# x70 - x7f # final packet (0 - 4096)
|
20
|
-
# x80 - xff # final packet for envelope (0 - 127)
|
21
|
-
#
|
22
|
-
#=== Hessian 2.0 Serialization Protocol Bytecode map
|
23
|
-
#
|
24
|
-
# x00 - x1f # utf-8 string length 0-31*
|
25
|
-
# x20 - x2f # binary data length 0-15*
|
26
|
-
# x30 - x33 # utf-8 string length 0-1023
|
27
|
-
# x34 - x37 # binary data length 0-1023
|
28
|
-
# x38 - x3f # three-octet compact long (-x40000 to x3ffff)
|
29
|
-
# x40 # reserved (expansion/escape)
|
30
|
-
# x41 # 8-bit binary data non-final chunk ('A')
|
31
|
-
# x42 # 8-bit binary data final chunk ('B')
|
32
|
-
# x43 # object type definition ('C')
|
33
|
-
# x44 # 64-bit IEEE encoded double ('D')
|
34
|
-
# x45 # reserved
|
35
|
-
# x46 # boolean false ('F')
|
36
|
-
# x47 # reserved
|
37
|
-
# x48 # untyped map ('H')
|
38
|
-
# x49 # 32-bit signed integer ('I')
|
39
|
-
# x4a # 64-bit UTC millisecond date
|
40
|
-
# x4b # 32-bit UTC minute date
|
41
|
-
# x4c # 64-bit signed long integer ('L')
|
42
|
-
# x4d # map with type ('M')
|
43
|
-
# x4e # null ('N')
|
44
|
-
# x4f # object instance ('O')
|
45
|
-
# x50 # reserved
|
46
|
-
# x51 # reference to map/list/object - integer ('Q')
|
47
|
-
# x52 # utf-8 string non-final chunk ('R')
|
48
|
-
# x53 # utf-8 string final chunk ('S')
|
49
|
-
# x54 # boolean true ('T')
|
50
|
-
# x55 # variable-length list/vector ('U')
|
51
|
-
# x56 # fixed-length list/vector ('V')
|
52
|
-
# x57 # variable-length untyped list/vector ('W')
|
53
|
-
# x58 # fixed-length untyped list/vector ('X')
|
54
|
-
# x59 # long encoded as 32-bit int ('Y')
|
55
|
-
# x5a # list/map terminator ('Z')
|
56
|
-
# x5b # double 0.0
|
57
|
-
# x5c # double 1.0
|
58
|
-
# x5d # double represented as byte (-128.0 to 127.0)
|
59
|
-
# x5e # double represented as short (-32768.0 to 32767.0)
|
60
|
-
# x5f # double represented as float
|
61
|
-
# x60 - x6f # object with direct type
|
62
|
-
# x70 - x77 # fixed list with direct length
|
63
|
-
# x78 - x7f # fixed untyped list with direct length
|
64
|
-
# x80 - xbf # one-octet compact int (-x10 to x2f, x90 is 0)*
|
65
|
-
# xc0 - xcf # two-octet compact int (-x800 to x7ff)
|
66
|
-
# xd0 - xd7 # three-octet compact int (-x40000 to x3ffff)
|
67
|
-
# xd8 - xef # one-octet compact long (-x8 to xf, xe0 is 0)
|
68
|
-
# xf0 - xff # two-octet compact long (-x800 to x7ff, xf8 is 0)
|
69
|
-
module Constants
|
70
|
-
BC_BINARY = 0x42
|
71
|
-
BC_BINARY_CHUNK = 0x41
|
72
|
-
BC_BINARY_DIRECT = 0x20
|
73
|
-
BINARY_DIRECT_MAX = 0x0f
|
74
|
-
BC_BINARY_SHORT = 0x34
|
75
|
-
BINARY_SHORT_MAX = 0x3ff
|
76
|
-
|
77
|
-
BC_CLASS_DEF = 0x43
|
78
|
-
|
79
|
-
BC_DATE = 0x4a
|
80
|
-
BC_DATE_MINUTE = 0x4b
|
81
|
-
|
82
|
-
BC_DOUBLE = 0x44
|
83
|
-
|
84
|
-
BC_DOUBLE_ZERO = 0x5b
|
85
|
-
BC_DOUBLE_ONE = 0x5c
|
86
|
-
BC_DOUBLE_BYTE = 0x5d
|
87
|
-
BC_DOUBLE_SHORT = 0x5e
|
88
|
-
BC_DOUBLE_MILL = 0x5f
|
89
|
-
|
90
|
-
BC_FALSE = 0x46
|
91
|
-
|
92
|
-
BC_INT = 0x49
|
93
|
-
|
94
|
-
INT_DIRECT_MIN = -0x10
|
95
|
-
INT_DIRECT_MAX = 0x2f
|
96
|
-
BC_INT_ZERO = 0x90
|
97
|
-
|
98
|
-
INT_BYTE_MIN = -0x800
|
99
|
-
INT_BYTE_MAX = 0x7ff
|
100
|
-
BC_INT_BYTE_ZERO = 0xc8
|
101
|
-
|
102
|
-
BC_END = 0x5a
|
103
|
-
|
104
|
-
INT_SHORT_MIN = -0x40000
|
105
|
-
INT_SHORT_MAX = 0x3ffff
|
106
|
-
BC_INT_SHORT_ZERO = 0xd4
|
107
|
-
|
108
|
-
BC_LIST_VARIABLE = 0x55
|
109
|
-
BC_LIST_FIXED = 0x56
|
110
|
-
BC_LIST_VARIABLE_UNTYPED = 0x57
|
111
|
-
BC_LIST_FIXED_UNTYPED = 0x58
|
112
|
-
|
113
|
-
BC_LIST_DIRECT = 0x70
|
114
|
-
BC_LIST_DIRECT_UNTYPED = 0x78
|
115
|
-
LIST_DIRECT_MAX = 0x7
|
116
|
-
|
117
|
-
BC_LONG = 0x4c
|
118
|
-
LONG_DIRECT_MIN = -0x08
|
119
|
-
LONG_DIRECT_MAX = 0x0f
|
120
|
-
BC_LONG_ZERO = 0xe0
|
121
|
-
|
122
|
-
LONG_BYTE_MIN = -0x800
|
123
|
-
LONG_BYTE_MAX = 0x7ff
|
124
|
-
BC_LONG_BYTE_ZERO = 0xf8
|
125
|
-
|
126
|
-
LONG_SHORT_MIN = -0x40000
|
127
|
-
LONG_SHORT_MAX = 0x3ffff
|
128
|
-
BC_LONG_SHORT_ZERO = 0x3c
|
129
|
-
|
130
|
-
BC_LONG_INT = 0x59
|
131
|
-
|
132
|
-
BC_MAP = 0x4d
|
133
|
-
BC_MAP_UNTYPED = 0x48
|
134
|
-
|
135
|
-
BC_NULL = 0x4e
|
136
|
-
|
137
|
-
BC_OBJECT = 0x4f
|
138
|
-
BC_OBJECT_DEF = 0x43
|
139
|
-
|
140
|
-
BC_OBJECT_DIRECT = 0x60
|
141
|
-
OBJECT_DIRECT_MAX = 0x0f
|
142
|
-
|
143
|
-
BC_REF = 0x51
|
144
|
-
|
145
|
-
BC_STRING = 0x53
|
146
|
-
BC_STRING_CHUNK = 0x52
|
147
|
-
|
148
|
-
BC_STRING_DIRECT = 0x00
|
149
|
-
STRING_DIRECT_MAX = 0x1f
|
150
|
-
BC_STRING_SHORT = 0x30
|
151
|
-
STRING_SHORT_MAX = 0x3ff
|
152
|
-
|
153
|
-
BC_TRUE = 0x54
|
154
|
-
|
155
|
-
P_PACKET_CHUNK = 0x4f
|
156
|
-
P_PACKET = 0x50
|
157
|
-
|
158
|
-
P_PACKET_DIRECT = 0x80
|
159
|
-
PACKET_DIRECT_MAX = 0x7f
|
160
|
-
|
161
|
-
P_PACKET_SHORT = 0x70
|
162
|
-
PACKET_SHORT_MAX = 0xfff
|
163
|
-
end
|
164
|
-
end
|
1
|
+
module Hessian2
|
2
|
+
#=== Hessian 2.0 Web Services Protocol Bytecode map
|
3
|
+
#
|
4
|
+
# x00 - x42 # reserved
|
5
|
+
# x43 # rpc call ('C')
|
6
|
+
# x44 # reserved
|
7
|
+
# x45 # envelope ('E')
|
8
|
+
# x46 # fault ('F')
|
9
|
+
# x47 # reserved
|
10
|
+
# x48 # hessian version ('H')
|
11
|
+
# x49 - x4f # reserved
|
12
|
+
# x4f # packet chunk ('O')
|
13
|
+
# x50 # packet end ('P')
|
14
|
+
# x51 # reserved
|
15
|
+
# x52 # rpc result ('R')
|
16
|
+
# x53 - x59 # reserved
|
17
|
+
# x5a # terminator ('Z')
|
18
|
+
# x5b - x5f # reserved
|
19
|
+
# x70 - x7f # final packet (0 - 4096)
|
20
|
+
# x80 - xff # final packet for envelope (0 - 127)
|
21
|
+
#
|
22
|
+
#=== Hessian 2.0 Serialization Protocol Bytecode map
|
23
|
+
#
|
24
|
+
# x00 - x1f # utf-8 string length 0-31*
|
25
|
+
# x20 - x2f # binary data length 0-15*
|
26
|
+
# x30 - x33 # utf-8 string length 0-1023
|
27
|
+
# x34 - x37 # binary data length 0-1023
|
28
|
+
# x38 - x3f # three-octet compact long (-x40000 to x3ffff)
|
29
|
+
# x40 # reserved (expansion/escape)
|
30
|
+
# x41 # 8-bit binary data non-final chunk ('A')
|
31
|
+
# x42 # 8-bit binary data final chunk ('B')
|
32
|
+
# x43 # object type definition ('C')
|
33
|
+
# x44 # 64-bit IEEE encoded double ('D')
|
34
|
+
# x45 # reserved
|
35
|
+
# x46 # boolean false ('F')
|
36
|
+
# x47 # reserved
|
37
|
+
# x48 # untyped map ('H')
|
38
|
+
# x49 # 32-bit signed integer ('I')
|
39
|
+
# x4a # 64-bit UTC millisecond date
|
40
|
+
# x4b # 32-bit UTC minute date
|
41
|
+
# x4c # 64-bit signed long integer ('L')
|
42
|
+
# x4d # map with type ('M')
|
43
|
+
# x4e # null ('N')
|
44
|
+
# x4f # object instance ('O')
|
45
|
+
# x50 # reserved
|
46
|
+
# x51 # reference to map/list/object - integer ('Q')
|
47
|
+
# x52 # utf-8 string non-final chunk ('R')
|
48
|
+
# x53 # utf-8 string final chunk ('S')
|
49
|
+
# x54 # boolean true ('T')
|
50
|
+
# x55 # variable-length list/vector ('U')
|
51
|
+
# x56 # fixed-length list/vector ('V')
|
52
|
+
# x57 # variable-length untyped list/vector ('W')
|
53
|
+
# x58 # fixed-length untyped list/vector ('X')
|
54
|
+
# x59 # long encoded as 32-bit int ('Y')
|
55
|
+
# x5a # list/map terminator ('Z')
|
56
|
+
# x5b # double 0.0
|
57
|
+
# x5c # double 1.0
|
58
|
+
# x5d # double represented as byte (-128.0 to 127.0)
|
59
|
+
# x5e # double represented as short (-32768.0 to 32767.0)
|
60
|
+
# x5f # double represented as float
|
61
|
+
# x60 - x6f # object with direct type
|
62
|
+
# x70 - x77 # fixed list with direct length
|
63
|
+
# x78 - x7f # fixed untyped list with direct length
|
64
|
+
# x80 - xbf # one-octet compact int (-x10 to x2f, x90 is 0)*
|
65
|
+
# xc0 - xcf # two-octet compact int (-x800 to x7ff)
|
66
|
+
# xd0 - xd7 # three-octet compact int (-x40000 to x3ffff)
|
67
|
+
# xd8 - xef # one-octet compact long (-x8 to xf, xe0 is 0)
|
68
|
+
# xf0 - xff # two-octet compact long (-x800 to x7ff, xf8 is 0)
|
69
|
+
module Constants
|
70
|
+
BC_BINARY = 0x42
|
71
|
+
BC_BINARY_CHUNK = 0x41
|
72
|
+
BC_BINARY_DIRECT = 0x20
|
73
|
+
BINARY_DIRECT_MAX = 0x0f
|
74
|
+
BC_BINARY_SHORT = 0x34
|
75
|
+
BINARY_SHORT_MAX = 0x3ff
|
76
|
+
|
77
|
+
BC_CLASS_DEF = 0x43
|
78
|
+
|
79
|
+
BC_DATE = 0x4a
|
80
|
+
BC_DATE_MINUTE = 0x4b
|
81
|
+
|
82
|
+
BC_DOUBLE = 0x44
|
83
|
+
|
84
|
+
BC_DOUBLE_ZERO = 0x5b
|
85
|
+
BC_DOUBLE_ONE = 0x5c
|
86
|
+
BC_DOUBLE_BYTE = 0x5d
|
87
|
+
BC_DOUBLE_SHORT = 0x5e
|
88
|
+
BC_DOUBLE_MILL = 0x5f
|
89
|
+
|
90
|
+
BC_FALSE = 0x46
|
91
|
+
|
92
|
+
BC_INT = 0x49
|
93
|
+
|
94
|
+
INT_DIRECT_MIN = -0x10
|
95
|
+
INT_DIRECT_MAX = 0x2f
|
96
|
+
BC_INT_ZERO = 0x90
|
97
|
+
|
98
|
+
INT_BYTE_MIN = -0x800
|
99
|
+
INT_BYTE_MAX = 0x7ff
|
100
|
+
BC_INT_BYTE_ZERO = 0xc8
|
101
|
+
|
102
|
+
BC_END = 0x5a
|
103
|
+
|
104
|
+
INT_SHORT_MIN = -0x40000
|
105
|
+
INT_SHORT_MAX = 0x3ffff
|
106
|
+
BC_INT_SHORT_ZERO = 0xd4
|
107
|
+
|
108
|
+
BC_LIST_VARIABLE = 0x55
|
109
|
+
BC_LIST_FIXED = 0x56
|
110
|
+
BC_LIST_VARIABLE_UNTYPED = 0x57
|
111
|
+
BC_LIST_FIXED_UNTYPED = 0x58
|
112
|
+
|
113
|
+
BC_LIST_DIRECT = 0x70
|
114
|
+
BC_LIST_DIRECT_UNTYPED = 0x78
|
115
|
+
LIST_DIRECT_MAX = 0x7
|
116
|
+
|
117
|
+
BC_LONG = 0x4c
|
118
|
+
LONG_DIRECT_MIN = -0x08
|
119
|
+
LONG_DIRECT_MAX = 0x0f
|
120
|
+
BC_LONG_ZERO = 0xe0
|
121
|
+
|
122
|
+
LONG_BYTE_MIN = -0x800
|
123
|
+
LONG_BYTE_MAX = 0x7ff
|
124
|
+
BC_LONG_BYTE_ZERO = 0xf8
|
125
|
+
|
126
|
+
LONG_SHORT_MIN = -0x40000
|
127
|
+
LONG_SHORT_MAX = 0x3ffff
|
128
|
+
BC_LONG_SHORT_ZERO = 0x3c
|
129
|
+
|
130
|
+
BC_LONG_INT = 0x59
|
131
|
+
|
132
|
+
BC_MAP = 0x4d
|
133
|
+
BC_MAP_UNTYPED = 0x48
|
134
|
+
|
135
|
+
BC_NULL = 0x4e
|
136
|
+
|
137
|
+
BC_OBJECT = 0x4f
|
138
|
+
BC_OBJECT_DEF = 0x43
|
139
|
+
|
140
|
+
BC_OBJECT_DIRECT = 0x60
|
141
|
+
OBJECT_DIRECT_MAX = 0x0f
|
142
|
+
|
143
|
+
BC_REF = 0x51
|
144
|
+
|
145
|
+
BC_STRING = 0x53
|
146
|
+
BC_STRING_CHUNK = 0x52
|
147
|
+
|
148
|
+
BC_STRING_DIRECT = 0x00
|
149
|
+
STRING_DIRECT_MAX = 0x1f
|
150
|
+
BC_STRING_SHORT = 0x30
|
151
|
+
STRING_SHORT_MAX = 0x3ff
|
152
|
+
|
153
|
+
BC_TRUE = 0x54
|
154
|
+
|
155
|
+
P_PACKET_CHUNK = 0x4f
|
156
|
+
P_PACKET = 0x50
|
157
|
+
|
158
|
+
P_PACKET_DIRECT = 0x80
|
159
|
+
PACKET_DIRECT_MAX = 0x7f
|
160
|
+
|
161
|
+
P_PACKET_SHORT = 0x70
|
162
|
+
PACKET_SHORT_MAX = 0xfff
|
163
|
+
end
|
164
|
+
end
|
data/lib/hessian2/fault.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Hessian2
|
2
|
-
class Fault < RuntimeError; end
|
3
|
-
end
|
1
|
+
module Hessian2
|
2
|
+
class Fault < RuntimeError; end
|
3
|
+
end
|
data/lib/hessian2/handler.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require 'hessian2'
|
2
|
-
|
3
|
-
module Hessian2
|
4
|
-
module Handler
|
5
|
-
|
6
|
-
def handle(data)
|
7
|
-
val = Hessian2.parse_rpc(data)
|
8
|
-
begin
|
9
|
-
res = self.send(*val)
|
10
|
-
rescue NoMethodError, ArgumentError => e
|
11
|
-
Hessian2.write_fault(e)
|
12
|
-
else
|
13
|
-
Hessian2.reply(res)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require 'hessian2'
|
2
|
+
|
3
|
+
module Hessian2
|
4
|
+
module Handler
|
5
|
+
|
6
|
+
def handle(data)
|
7
|
+
val = Hessian2.parse_rpc(data)
|
8
|
+
begin
|
9
|
+
res = self.send(*val)
|
10
|
+
rescue NoMethodError, ArgumentError => e
|
11
|
+
Hessian2.write_fault(e)
|
12
|
+
else
|
13
|
+
Hessian2.reply(res)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module Hessian2
|
2
|
-
class HessianClient < Client; end
|
3
|
-
end
|
1
|
+
module Hessian2
|
2
|
+
class HessianClient < Client; end
|
3
|
+
end
|