rack-json_response_wrapper 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rack/json_response_wrapper.rb +2 -2
- 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: 61c133c2d526f015d9f223b886de8e0f39e08417
|
4
|
+
data.tar.gz: 108cfccb51f6368ccc3984a4e7a909392c71a49e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df23e99db9d44a09eb8701e3aae86788ac9f90492af844cc085d87ab6c487820efe4b0c3733afdae9289f7b23c5c0aa36e83c51dfd36834bd1efafe456bca7f
|
7
|
+
data.tar.gz: b5d5dfbccfd8f49741aa6d94af061effee9440ddddf401d1975093d99c1d2353bd01fb017beefe0deac2a37c65f152938638b75ec17fd2e9601668d365b3824b
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ rack-json_response_wrapper
|
|
3
3
|
|
4
4
|
Rack Middleware for JSON APIs accessed cross-domain from legacy browsers
|
5
5
|
|
6
|
-
Firefox
|
6
|
+
Firefox versions <4 does not support response headers for cross-domain requests. This middleware intercepts all requests and if the X-WRAP-RESPONSE is set, the response will be wrappped in JSON as follows:
|
7
7
|
|
8
8
|
Suppose the following is the original response body:
|
9
9
|
|
@@ -47,9 +47,9 @@ module Rack
|
|
47
47
|
# when we change the content-length, the length will change.
|
48
48
|
# therefore, calculate the offset by comparing the length of the old vs. new
|
49
49
|
original_content_length = response_header['Content-Length']
|
50
|
-
new_content_length = wrapped_body.
|
50
|
+
new_content_length = wrapped_body.bytesize
|
51
51
|
adjusted_content_length =
|
52
|
-
new_content_length.to_s.to_json.
|
52
|
+
new_content_length.to_s.to_json.bytesize - original_content_length.to_s.to_json.bytesize
|
53
53
|
|
54
54
|
# adjust the new content-length by this offset
|
55
55
|
new_content_length += adjusted_content_length
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-json_response_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- g. nicholas d'andrea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|