akita-har_logger 0.2.6 → 0.2.10

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
  SHA256:
3
- metadata.gz: cc8020afb47521c9d7d9ca923dca64e2a8f8364ff7207ab80b68cdc09cd0ca39
4
- data.tar.gz: aa865b2768013560e4439d9e500df4680276af28f88294113aa1a594545938eb
3
+ metadata.gz: 26fd1b1b5e2ccf962928f85e6969b50f63766571f40cf442cf5b615bb44559e9
4
+ data.tar.gz: b6e0ef99924d4b9db81fa0c0981cdc84d41e11930493843c110bc595bdee9447
5
5
  SHA512:
6
- metadata.gz: 2f6b7d249bcde1e1d4dea4c332bd1527c1176b7a138ae7dc36edf7844d043e07cea25f845783634fac9385216f746b6209b69e0d4a04eb5b17b2693d5aa9156e
7
- data.tar.gz: b58e4e46383ab4caa08b0338cf85b2921c049c7d99df79146756fc2520e267600e1139654059c9ce43faf2807097316a9e874e386fc5c00ee7c2e31e65fb0c0b
6
+ metadata.gz: c4953346d8f0f2169aea261ebab4768e3868cfbd0511c0d276791b06b6c2e5871f5d054b869b2d3fed0c99eb5d3cad7712bf7a9dd15d2698052da5e22ff3d756
7
+ data.tar.gz: bc46a89f9eeea951a20e34ed9a2bab0c9dee5fd7a8e5ed996d2fe06942d917279345bae0e12c662a0423baff927790dde4c82a99baf834537615deb1d62b796e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akita-har_logger (0.2.6)
4
+ akita-har_logger (0.2.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -37,14 +37,27 @@ module Akita
37
37
 
38
38
  def call(env)
39
39
  start_time = Time.now
40
+
41
+ # Read the request body here, in case there is non-Rack-compliant
42
+ # middleware in the stack that closes the request-body stream on us.
43
+ request_body = env['rack.input'].read
44
+ env['rack.input'].rewind # Be kind.
45
+
40
46
  status, headers, body = @app.call(env)
41
47
  end_time = Time.now
42
48
 
43
49
  wait_time_ms = ((end_time.to_f - start_time.to_f) * 1000).round
44
50
 
51
+ # Patch env with our saved request body.
52
+ saved_input = env['rack.input']
53
+ env['rack.input'] = StringIO.new request_body
54
+
45
55
  @entry_queue << (HarEntry.new start_time, wait_time_ms, env, status,
46
56
  headers, body)
47
57
 
58
+ # Be kind and restore the original request-body stream.
59
+ env['rack.input'] = saved_input
60
+
48
61
  [ status, headers, body ]
49
62
  end
50
63
  end
@@ -72,6 +85,11 @@ module Akita
72
85
  def around(controller)
73
86
  start_time = Time.now
74
87
 
88
+ # Read the request body here, in case there is non-Rack-compliant
89
+ # middleware in the stack that closes the request-body stream on us.
90
+ request_body = controller.response.request.env['rack.input'].read
91
+ controller.response.request.env['rack.input'].rewind # Be kind.
92
+
75
93
  yield
76
94
 
77
95
  end_time = Time.now
@@ -80,9 +98,16 @@ module Akita
80
98
  response = controller.response
81
99
  request = response.request
82
100
 
101
+ # Patch env with our saved request body.
102
+ saved_input = request.env['rack.input']
103
+ request.env['rack.input'] = StringIO.new request_body
104
+
83
105
  @entry_queue << (HarEntry.new start_time, wait_time_ms, request.env,
84
106
  response.status, response.headers,
85
107
  [response.body])
108
+
109
+ # Be kind and restore the original request-body stream.
110
+ request.env['rack.input'] = saved_input
86
111
  end
87
112
  end
88
113
 
@@ -39,7 +39,7 @@ module Akita
39
39
  hash.reduce([]) { |accum, (k, v)|
40
40
  accum.append({
41
41
  name: fixEncoding(k),
42
- value: fixEncoding(v),
42
+ value: fixEncoding(v.to_s),
43
43
  })
44
44
  }
45
45
  end
@@ -121,7 +121,8 @@ module Akita
121
121
  # Gracefully handle any characters that are invalid in the source
122
122
  # encoding and characters that have no UTF-8 representation by
123
123
  # replacing with '?'. Log a warning when this happens.
124
- source = req.body.string.force_encoding(getPostDataCharSet(env))
124
+ sourceCharset = getPostDataCharSet(env)
125
+ source = String.new(req.body.read).force_encoding(sourceCharset)
125
126
  utf8EncodingSuccessful = false
126
127
  if source.valid_encoding? then
127
128
  begin
@@ -153,7 +153,7 @@ module Akita
153
153
  # for the CRLF on the blank line.
154
154
  headers.reduce(status_length + 2) { |accum, (k, v)|
155
155
  # Header-Name: header value<CR><LF>
156
- accum + k.length + 2 + v.length + 2
156
+ accum + k.length + 2 + v.to_s.length + 2
157
157
  }
158
158
  end
159
159
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Akita
4
4
  module HarLogger
5
- VERSION = "0.2.6"
5
+ VERSION = "0.2.10"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akita-har_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jed Liu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-13 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec