hprose 1.4.7 → 1.4.8
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/lib/hprose/httpclient.rb +1 -2
- data/lib/hprose/httpservice.rb +0 -5
- data/lib/hprose/service.rb +40 -11
- metadata +4 -7
data/lib/hprose/httpclient.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# #
|
15
15
|
# hprose http client for ruby #
|
16
16
|
# #
|
17
|
-
# LastModified: Mar
|
17
|
+
# LastModified: Mar 12, 2014 #
|
18
18
|
# Author: Ma Bingyao <andot@hprose.com> #
|
19
19
|
# #
|
20
20
|
############################################################
|
@@ -55,7 +55,6 @@ module Hprose
|
|
55
55
|
httpclient.open_timeout = @timeout
|
56
56
|
httpclient.read_timeout = @timeout
|
57
57
|
httpclient.use_ssl = (@uri.scheme == 'https')
|
58
|
-
#httpclient.set_debug_output $stderr
|
59
58
|
httpclient.start
|
60
59
|
headers = {'Content-Type' => 'application/hprose',
|
61
60
|
'Connection' => 'close'}
|
data/lib/hprose/httpservice.rb
CHANGED
@@ -95,11 +95,6 @@ module Hprose
|
|
95
95
|
header['Content-Length'] = body.size.to_s
|
96
96
|
return [statuscode, header, [body]]
|
97
97
|
end
|
98
|
-
protected
|
99
|
-
def fix_args(args, arity, context)
|
100
|
-
session = context['rack.session'] ? context['rack.session'] : {}
|
101
|
-
((arity > 0) and (args.length + 1 == arity)) ? args + [session] : args
|
102
|
-
end
|
103
98
|
private
|
104
99
|
def crossdomain_xml_handler(context)
|
105
100
|
path = (context['SCRIPT_NAME'] << context['PATH_INFO']).downcase
|
data/lib/hprose/service.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# #
|
15
15
|
# hprose service for ruby #
|
16
16
|
# #
|
17
|
-
# LastModified: Mar
|
17
|
+
# LastModified: Mar 12, 2014 #
|
18
18
|
# Author: Ma Bingyao <andot@hprose.com> #
|
19
19
|
# #
|
20
20
|
############################################################
|
@@ -243,14 +243,43 @@ module Hprose
|
|
243
243
|
ostream.close
|
244
244
|
return data
|
245
245
|
end
|
246
|
-
def fix_args(args,
|
247
|
-
args
|
246
|
+
def fix_args(args, function, context)
|
247
|
+
(args.length + 1 == function.arity) ? args + [context] : args
|
248
248
|
end
|
249
|
-
def
|
250
|
-
|
249
|
+
def fire_before_invoke_event(name, args, byref, context)
|
250
|
+
unless @on_before_invoke.nil? then
|
251
|
+
case @on_before_invoke.arity
|
252
|
+
when 0 then @on_before_invoke.call()
|
253
|
+
when 1 then @on_before_invoke.call(name)
|
254
|
+
when 2 then @on_before_invoke.call(name, args)
|
255
|
+
when 3 then @on_before_invoke.call(name, args, byref)
|
256
|
+
else @on_before_invoke.call(name, args, byref, context)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
def fire_after_invoke_event(name, args, byref, result, context)
|
261
|
+
unless @on_after_invoke.nil? then
|
262
|
+
case @on_after_invoke.arity
|
263
|
+
when 0 then @on_after_invoke.call()
|
264
|
+
when 1 then @on_after_invoke.call(name)
|
265
|
+
when 2 then @on_after_invoke.call(name, args)
|
266
|
+
when 3 then @on_after_invoke.call(name, args, byref)
|
267
|
+
when 4 then @on_after_invoke.call(name, args, byref, result)
|
268
|
+
else @on_after_invoke.call(name, args, byref, result, context)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
def fire_error_event(e, context)
|
273
|
+
unless @on_send_error.nil? then
|
274
|
+
case @on_send_error.arity
|
275
|
+
when 0 then @on_send_error.call()
|
276
|
+
when 1 then @on_send_error.call(e)
|
277
|
+
else @on_send_error.call(e, context)
|
278
|
+
end
|
279
|
+
end
|
251
280
|
end
|
252
|
-
def do_error(e)
|
253
|
-
fire_error_event(e)
|
281
|
+
def do_error(e, context)
|
282
|
+
fire_error_event(e, context)
|
254
283
|
error = @debug ? e.backtrace.unshift(e.message).join("\r\n") : e.message
|
255
284
|
ostream = StringIO.new
|
256
285
|
writer = Writer.new(ostream, true)
|
@@ -277,13 +306,13 @@ module Hprose
|
|
277
306
|
tag = reader.check_tags([TagCall, TagEnd])
|
278
307
|
end
|
279
308
|
end
|
280
|
-
|
309
|
+
fire_before_invoke_event(name, args, byref, context)
|
281
310
|
result = nil
|
282
311
|
if @functions.has_key?(aliasname) then
|
283
312
|
function = @functions[aliasname]
|
284
313
|
resultMode = @resultMode[aliasname]
|
285
314
|
simple = @simpleMode[aliasname]
|
286
|
-
result = function.call(*fix_args(args, function
|
315
|
+
result = function.call(*fix_args(args, function, context))
|
287
316
|
elsif @functions.has_key?('*') then
|
288
317
|
function = @functions['*']
|
289
318
|
resultMode = @resultMode['*']
|
@@ -292,7 +321,7 @@ module Hprose
|
|
292
321
|
else
|
293
322
|
raise Exception.exception("Can't find this function " << name)
|
294
323
|
end
|
295
|
-
|
324
|
+
fire_after_invoke_event(name, args, byref, result, context)
|
296
325
|
ostream = StringIO.new
|
297
326
|
if resultMode == RawWithEndTag then
|
298
327
|
ostream.write(result)
|
@@ -338,7 +367,7 @@ module Hprose
|
|
338
367
|
else raise Exception.exception("Wrong Request: \r\n#{data}")
|
339
368
|
end
|
340
369
|
rescue ::Exception => e
|
341
|
-
return do_error(e)
|
370
|
+
return do_error(e, context)
|
342
371
|
ensure
|
343
372
|
istream.close unless istream.nil?
|
344
373
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hprose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,12 +16,9 @@ description: ! " Hprose is a High Performance Remote Object Service Engine.\n\n
|
|
16
16
|
performance, remote dynamic communication middleware. It is not only easy to use,
|
17
17
|
but powerful. You just need a little time to learn, then you can use it to easily
|
18
18
|
construct cross language cross platform distributed application system.\n\n Hprose
|
19
|
-
supports many programming languages
|
20
|
-
|
21
|
-
|
22
|
-
\ ...\n\n Through Hprose, You can conveniently and efficiently intercommunicate
|
23
|
-
between those programming languages.\n\n This project is the implementation of
|
24
|
-
Hprose for Ruby.\n"
|
19
|
+
supports many programming languages.\n\n Through Hprose, You can conveniently and
|
20
|
+
efficiently intercommunicate between those programming languages.\n\n This project
|
21
|
+
is the implementation of Hprose for Ruby.\n"
|
25
22
|
email: andot@hprose.com
|
26
23
|
executables: []
|
27
24
|
extensions: []
|