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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/akita/har_logger.rb +25 -0
- data/lib/akita/har_logger/http_request.rb +1 -1
- data/lib/akita/har_logger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26fd1b1b5e2ccf962928f85e6969b50f63766571f40cf442cf5b615bb44559e9
|
4
|
+
data.tar.gz: b6e0ef99924d4b9db81fa0c0981cdc84d41e11930493843c110bc595bdee9447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4953346d8f0f2169aea261ebab4768e3868cfbd0511c0d276791b06b6c2e5871f5d054b869b2d3fed0c99eb5d3cad7712bf7a9dd15d2698052da5e22ff3d756
|
7
|
+
data.tar.gz: bc46a89f9eeea951a20e34ed9a2bab0c9dee5fd7a8e5ed996d2fe06942d917279345bae0e12c662a0423baff927790dde4c82a99baf834537615deb1d62b796e
|
data/Gemfile.lock
CHANGED
data/lib/akita/har_logger.rb
CHANGED
@@ -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.
|
125
|
+
source = String.new(req.body.read).force_encoding(sourceCharset)
|
126
126
|
utf8EncodingSuccessful = false
|
127
127
|
if source.valid_encoding? then
|
128
128
|
begin
|
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.
|
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-
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|