fluoride-collector 0.0.2 → 0.0.3

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: e105ac67bef95d43c62790318839abbd6fe991eb
4
- data.tar.gz: 888928f7e2a84edab100ca809c51788bf1ece05f
3
+ metadata.gz: cf7c03aa82878bb35ce0803cf3fafc97821809aa
4
+ data.tar.gz: 6011f540fff63c4babdbf8e449c20f634c227113
5
5
  SHA512:
6
- metadata.gz: bc2e0053d0b0cdbe700dffa08514b38990a88640bd059d6c01ab9bc56d3f654b0cff179889eae9585133c0d7fe89b4e0feed935e38d4da8df7094627cce5d56e
7
- data.tar.gz: e07ceb9cfde86ead95d37a32f5e621c2555f0f8a33fa6278ca224ad3f31ec3f1314f6cae95f9d18c86d822921f6a3e82d7585406b21bb9b14ba40b40eb9ec778
6
+ metadata.gz: d296dd8d97c1d6d85750cb366588bbd9cb6f29fc701a7a04c9e12c99c9b707e7b8eb9565287b394d16d2ef9a485948c3194e7b8f86a20579da69a7a42b730934
7
+ data.tar.gz: 54fb62bc45b2300147f71920cc804860e7f99ad399d9913bd1efae8237ce7692201ff95b1597b1edbf0bc4fa2234d36a9a924f05ceaa16321fb536e1fe061eff
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Fluoride
2
4
  module Collector
3
5
  class Middleware
@@ -43,13 +45,30 @@ module Fluoride
43
45
  end
44
46
  end
45
47
 
48
+ def clean_hash(hash)
49
+ hash.each_key do |key|
50
+ value = hash[key]
51
+ case value
52
+ when String
53
+ if value.ascii_only?
54
+ value = value.dup
55
+ value.force_encoding("US-ASCII")
56
+ hash[key] = value
57
+ end
58
+ when Hash
59
+ hash[key] = clean_hash(value)
60
+ end
61
+ end
62
+ hash
63
+ end
64
+
46
65
  def request_hash(env)
47
66
  body = nil
48
67
  if env['rack.input'].respond_to? :read
49
68
  body = env['rack.input'].read
50
69
  env['rack.input'].rewind rescue nil
51
70
  end
52
- {
71
+ clean_hash(
53
72
  "content_type" => env['CONTENT_TYPE'],
54
73
  "accept" => env["HTTP_ACCEPT_ENCODING"],
55
74
  "referer" => env["HTTP_REFERER"],
@@ -57,22 +76,22 @@ module Fluoride
57
76
  "authorization" => env["HTTP_AUTHORIZATION"],
58
77
  "method" => env["REQUEST_METHOD"],
59
78
  "host" => env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}",
60
- "path" => env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s,
79
+ "path" => URI.unescape(env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s),
61
80
  "query_string" => env["QUERY_STRING"].to_s,
62
81
  "body" => body,
63
- }
82
+ )
64
83
  end
65
84
 
66
85
  class CollectExceptions < Middleware
67
86
  def call(env)
68
87
  @app.call(env)
69
88
  rescue Object => ex
70
- store(
71
- "type" => "exception_raised",
72
- "tags" => @tagging,
73
- "request" => request_hash(env),
74
- "response" => exception_hash(ex)
75
- )
89
+ store( clean_hash(
90
+ "type" => "exception_raised",
91
+ "tags" => @tagging,
92
+ "request" => request_hash(env),
93
+ "response" => exception_hash(ex)
94
+ ))
76
95
  raise
77
96
  end
78
97
 
@@ -94,12 +113,12 @@ module Fluoride
94
113
  class CollectExchanges < Middleware
95
114
  def call(env)
96
115
  @app.call(env).tap do |response|
97
- store(
116
+ store( clean_hash(
98
117
  "type" => "normal_exchange",
99
118
  "tags" => @tagging,
100
119
  "request" => request_hash(env),
101
120
  "response" => response_hash(response)
102
- )
121
+ ))
103
122
  end
104
123
  end
105
124
 
@@ -123,7 +142,7 @@ module Fluoride
123
142
 
124
143
  {
125
144
  "status" => status,
126
- "headers" => headers,
145
+ "headers" => headers.to_hash,
127
146
  "body" => extract_body(body)
128
147
  }
129
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluoride-collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-14 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Part of the Fluoride suite - tools for making your black box a bit whiter
@@ -38,7 +38,7 @@ rdoc_options:
38
38
  - --main
39
39
  - doc/README
40
40
  - --title
41
- - fluoride-collector-0.0.2 Documentation
41
+ - fluoride-collector-0.0.3 Documentation
42
42
  require_paths:
43
43
  - lib/
44
44
  required_ruby_version: !ruby/object:Gem::Requirement