hprose 1.4.12 → 1.4.13

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.
Files changed (2) hide show
  1. data/lib/hprose/httpservice.rb +12 -3
  2. metadata +2 -2
@@ -14,7 +14,7 @@
14
14
  # #
15
15
  # hprose http service for ruby #
16
16
  # #
17
- # LastModified: Mar 19, 2014 #
17
+ # LastModified: Apr 18, 2014 #
18
18
  # Author: Ma Bingyao <andot@hprose.com> #
19
19
  # #
20
20
  ############################################################
@@ -29,6 +29,7 @@ module Hprose
29
29
  @crossdomain = false
30
30
  @p3p = false
31
31
  @get = true
32
+ @origins = {}
32
33
  @crossdomain_xml_file = nil
33
34
  @crossdomain_xml_content = nil
34
35
  @client_access_policy_xml_file = nil
@@ -45,6 +46,12 @@ module Hprose
45
46
  attr_reader :crossdomain_xml_content
46
47
  attr_reader :client_access_policy_xml_file
47
48
  attr_reader :client_access_policy_xml_content
49
+ def add_access_control_allow_origin(origin)
50
+ @origins[origin] = true
51
+ end
52
+ def remove_access_control_allow_origin(origin)
53
+ @origins.delete(origin)
54
+ end
48
55
  def crossdomain_xml_file=(filepath)
49
56
  @crossdomain_xml_file = filepath
50
57
  f = File.open(filepath)
@@ -140,8 +147,10 @@ module Hprose
140
147
  if @crossdomain then
141
148
  origin = context['HTTP_ORIGIN']
142
149
  if (origin and origin != 'null') then
143
- header['Access-Control-Allow-Origin'] = origin
144
- header['Access-Control-Allow-Credentials'] = 'true'
150
+ if (@origins.size == 0) or @origins.has_key?(origin) then
151
+ header['Access-Control-Allow-Origin'] = origin
152
+ header['Access-Control-Allow-Credentials'] = 'true'
153
+ end
145
154
  else
146
155
  header['Access-Control-Allow-Origin'] = '*'
147
156
  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.12
4
+ version: 1.4.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-12 00:00:00.000000000 Z
12
+ date: 2014-04-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! " Hprose is a High Performance Remote Object Service Engine.\n\n It
15
15
  is a modern, lightweight, cross-language, cross-platform, object-oriented, high