akita-har_logger 0.2.5 → 0.2.6
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/har_utils.rb +18 -7
- data/lib/akita/har_logger/http_request.rb +1 -1
- data/lib/akita/har_logger/http_response.rb +40 -3
- 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: cc8020afb47521c9d7d9ca923dca64e2a8f8364ff7207ab80b68cdc09cd0ca39
|
4
|
+
data.tar.gz: aa865b2768013560e4439d9e500df4680276af28f88294113aa1a594545938eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6b7d249bcde1e1d4dea4c332bd1527c1176b7a138ae7dc36edf7844d043e07cea25f845783634fac9385216f746b6209b69e0d4a04eb5b17b2693d5aa9156e
|
7
|
+
data.tar.gz: b58e4e46383ab4caa08b0338cf85b2921c049c7d99df79146756fc2520e267600e1139654059c9ce43faf2807097316a9e874e386fc5c00ee7c2e31e65fb0c0b
|
data/Gemfile.lock
CHANGED
@@ -9,15 +9,26 @@ module Akita
|
|
9
9
|
# If we are unable to do this reinterpretation, return the string
|
10
10
|
# unchanged, but log a warning that points to the caller.
|
11
11
|
def self.fixEncoding(v)
|
12
|
-
if v
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
if v == nil then
|
13
|
+
return v
|
14
|
+
end
|
15
|
+
|
16
|
+
if !(v.is_a? String) then
|
17
|
+
Rails.logger.warn "[#{caller_locations(1, 1)}] fixEncoding was not given a string. This might cause JSON serialization to fail."
|
18
|
+
return v
|
19
|
+
end
|
20
|
+
|
21
|
+
# Only re-interpret 8-bit ASCII.
|
22
|
+
if v.encoding != Encoding::ASCII_8BIT then
|
23
|
+
return v
|
24
|
+
end
|
25
|
+
|
26
|
+
forced = String.new(v).force_encoding(Encoding::UTF_8)
|
27
|
+
if forced.valid_encoding? then
|
28
|
+
return forced
|
19
29
|
end
|
20
30
|
|
31
|
+
Rails.logger.warn "[#{caller_locations(1, 1)}] Unable to fix encoding: not a valid UTF-8 string. This will likely cause JSON serialization to fail."
|
21
32
|
v
|
22
33
|
end
|
23
34
|
|
@@ -74,14 +74,51 @@ module Akita
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def getContent(headers, body)
|
77
|
-
# XXX Handle compression
|
77
|
+
# XXX Handle compression
|
78
|
+
# XXX Figure out how to properly join together multi-part bodies.
|
78
79
|
|
80
|
+
# Try to convert the body into UTF-8. If this fails, assume the body is
|
81
|
+
# binary data.
|
82
|
+
# XXX TODO Take charset part of Content-Type header into account.
|
79
83
|
text = +""
|
84
|
+
haveBinaryData = false
|
80
85
|
body.each { |part|
|
81
|
-
|
82
|
-
|
86
|
+
partStr = part.to_s
|
87
|
+
|
88
|
+
if partStr.encoding == Encoding::ASCII_8BIT then
|
89
|
+
# Have 8-bit ASCII data. Try to interpret as UTF-8. If this fails,
|
90
|
+
# treat as binary data.
|
91
|
+
forced = String.new(partStr).force_encoding(Encoding::UTF_8)
|
92
|
+
if forced.valid_encoding? then
|
93
|
+
text << forced
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
haveBinaryData = true
|
98
|
+
break
|
99
|
+
end
|
100
|
+
|
101
|
+
if !partStr.valid_encoding? then
|
102
|
+
# Source encoding is not valid. Treat as binary data.
|
103
|
+
haveBinaryData = true
|
104
|
+
break
|
105
|
+
end
|
106
|
+
|
107
|
+
# Try to re-encode as UTF-8. If this fails, treat as binary data.
|
108
|
+
begin
|
109
|
+
text << partStr.encode(Encoding::UTF_8)
|
110
|
+
rescue Encoding::UndefinedConversionError
|
111
|
+
haveBinaryData = true
|
112
|
+
break
|
113
|
+
end
|
83
114
|
}
|
84
115
|
|
116
|
+
if haveBinaryData then
|
117
|
+
# TODO Encode binary body data with base64.
|
118
|
+
# XXX Omit for now.
|
119
|
+
text = ""
|
120
|
+
end
|
121
|
+
|
85
122
|
{
|
86
123
|
size: getBodySize(body),
|
87
124
|
|
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.6
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|