akita-har_logger 0.2.9 → 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: c1366b8824f9cd610742238604c0d162845132a67dd67e9763542ae271cf0b7d
4
- data.tar.gz: 2ca5e09f1f65045405ce549b194fa4a51573663f43e1f3ecdde5c73d930538c2
3
+ metadata.gz: 26fd1b1b5e2ccf962928f85e6969b50f63766571f40cf442cf5b615bb44559e9
4
+ data.tar.gz: b6e0ef99924d4b9db81fa0c0981cdc84d41e11930493843c110bc595bdee9447
5
5
  SHA512:
6
- metadata.gz: 82b07817b21e2e05c0f5c5139370c7bdd9b712dcd02e134b9d52be1d1ce95a00e4ff200067c0797a9be1a1f2b56a0518a2fac0526696bb3de3700f8f58c9bd44
7
- data.tar.gz: 45ea9d1c479cb47f481c1b3fb7eba1dc8032dc692dc69d478e8cba98b2abb14d94e685efff5d5591785a871ddecc787166c99f70ceb2d99fc5f6961803f27a49
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.9)
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
 
@@ -122,7 +122,7 @@ module Akita
122
122
  # encoding and characters that have no UTF-8 representation by
123
123
  # replacing with '?'. Log a warning when this happens.
124
124
  sourceCharset = getPostDataCharSet(env)
125
- source = String.new(req.body.string).force_encoding(sourceCharset)
125
+ source = String.new(req.body.read).force_encoding(sourceCharset)
126
126
  utf8EncodingSuccessful = false
127
127
  if source.valid_encoding? then
128
128
  begin
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Akita
4
4
  module HarLogger
5
- VERSION = "0.2.9"
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.9
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-19 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