web-connect 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 273dc9f8b0c167f981f7dc726a5a2c90b4b3cca9
4
- data.tar.gz: cf3251442213fa65617e0b69591345596efbf294
3
+ metadata.gz: 52cd6dd3ae425d48864e984ed72dd41b35ef1f4a
4
+ data.tar.gz: ec3b4953d6f45e8be6074fb603145da6e78ba2a0
5
5
  SHA512:
6
- metadata.gz: b7c425a18993a3ef9138327ced689d54f82ca5acb214e119b24c9bf41ca7ef7682070bbf2a70c4f43627b3c77978d28d56b430995c9aa8cbcc845ff7fc4352a1
7
- data.tar.gz: a94076bac46ff5f1a6ef825a47d3895b7b54910155284b120556a50c6dbddd0b6ee54ec4b3fb0c2ddb3638dcc05d39682b0efa5c644f2d5e291060c18e96a158
6
+ metadata.gz: e455749ad8bb95f79ebd8947eb3f4d02572ad7bfad0009cb5a40b042de0aa9791d9414536941fe9648c09fc6c8d4cde9c9d61974d7f50d8515612bd51f22f98e
7
+ data.tar.gz: 6c8036b621934fb75db6ba1d082d8f370fb00e6d3c11039bdea5c86e0d91e8a721b4932ab8a860f6a5ad3c1b386f8094a311ac892ac2ceeb03a275bcb550d1c0
@@ -9,21 +9,42 @@ module Netfira::WebConnect
9
9
  end
10
10
 
11
11
  def call(env)
12
- if (env['CONTENT_TYPE'] || env['HTTP_CONTENT_TYPE']) == 'application/x-netfira-webconnect-packed'
13
- begin
14
- unpack env
15
- rescue Zlib::GzipFile::Error => e
16
- return [400, {}, {errorCode: 19, errorMessage: "Gzip decompression error: #{e.message}"}]
12
+ begin
13
+ if (env['CONTENT_TYPE'] || env['HTTP_CONTENT_TYPE']) == 'application/x-netfira-webconnect-packed'
14
+ begin
15
+ unpack env
16
+ rescue Zlib::GzipFile::Error, Zlib::DataError => e
17
+ return [400, {}, {errorCode: 19, errorMessage: "Decompression error: #{e.message}"}]
18
+ end
17
19
  end
20
+ env['WC_ACCEPTABLE_REQUEST_TYPES'] = %w[packed unpacked]
21
+ @app.call env
22
+ rescue Exception => error
23
+ # TODO: this mirrors code in rack_app.rb. Consolidate?
24
+ [
25
+ 500,
26
+ {'Content-Type' => 'application/json'},
27
+ {
28
+ errorCode: 1,
29
+ errorMessage: 'Uncaught Exception',
30
+ exception: {
31
+ class: error.class.name,
32
+ message: error.message,
33
+ backtrace: error.backtrace
34
+ }
35
+ }
36
+ ]
18
37
  end
19
- env['WC_ACCEPTABLE_REQUEST_TYPES'] = %w[packed unpacked]
20
- @app.call env
21
38
  end
22
39
 
23
40
  def unpack(env)
24
41
  env['original.rack.input'] = input = env['rack.input']
25
42
 
26
- input = Zlib::GzipReader.new(input) if (env['CONTENT_ENCODING'] || env['HTTP_CONTENT_ENCODING']) == 'gzip'
43
+ input = case env['CONTENT_ENCODING'] || env['HTTP_CONTENT_ENCODING']
44
+ when 'gzip' then Zlib::GzipReader.new(input)
45
+ when 'deflate' then StringIO.new(Zlib::Inflate.inflate input.read)
46
+ else input
47
+ end
27
48
 
28
49
  method, path, query_string, headers, body = parse_request(input)
29
50
 
@@ -1,6 +1,6 @@
1
1
  module Netfira
2
2
  module WebConnect
3
- VERSION = '0.4.12'
3
+ VERSION = '0.4.13'
4
4
  PLATFORM_AND_VERSION = 'Rack/' << VERSION
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-18 00:00:00.000000000 Z
12
+ date: 2014-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord