better-faraday 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/better-faraday.gemspec +1 -1
- data/lib/better-faraday.rb +43 -8
- 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: 3c28a4a8921cc595ea37a968efe8127a9ac3da2044ff76168bfe076761965a93
|
4
|
+
data.tar.gz: 937005a9d7e8dea011d3872e42f470bded405821186e414bcea64b0cd9953367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 142c021bc1f27154292f8ce8a8b52ba5742cea07d34d3d7bf5b69700655bb83ae51be5ca89ac4444863711d66d1289116c9be5379d4e7d893f4ef70d29c7aef0
|
7
|
+
data.tar.gz: f3a5b027c3be795db544b320b66edcdf537577f580fc231e7ee40e8bdad6935e5d1beb57f9c27e704e6a8c5b1d2b5ba1faf0333ca6dde5aa0724d982eec9b43d
|
data/better-faraday.gemspec
CHANGED
data/lib/better-faraday.rb
CHANGED
@@ -71,10 +71,19 @@ module Faraday
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def describe
|
74
|
-
request_headers
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
request_headers = __protect_data(env.request_headers.deep_dup)
|
75
|
+
|
76
|
+
if env.request_headers["Content-Type"].to_s.match?(/\bapplication\/json\b/)
|
77
|
+
request_json = __protect_data(__parse_json(env.request_body.dup))
|
78
|
+
end
|
79
|
+
|
80
|
+
if env.response_headers
|
81
|
+
response_headers = __protect_data(env.response_headers.deep_dup)
|
82
|
+
end
|
83
|
+
|
84
|
+
if env.response_headers && env.response_headers["Content-Type"].to_s.match?(/\bapplication\/json\b/)
|
85
|
+
response_json = __protect_data(__parse_json(env.body.dup))
|
86
|
+
end
|
78
87
|
|
79
88
|
lines = [
|
80
89
|
"",
|
@@ -89,17 +98,43 @@ module Faraday
|
|
89
98
|
"-- Request headers --",
|
90
99
|
::JSON.generate(request_headers).yield_self { |t| t.truncate(2048, omission: "... (truncated, full length: #{t.length})") },
|
91
100
|
"",
|
101
|
+
|
92
102
|
"-- Request body --",
|
93
|
-
|
103
|
+
if request_json
|
104
|
+
::JSON.generate(request_json)
|
105
|
+
else
|
106
|
+
body = env.request_body.to_s.dup
|
107
|
+
if body.encoding.name == "ASCII-8BIT"
|
108
|
+
"Binary (#{body.size} bytes)"
|
109
|
+
else
|
110
|
+
body
|
111
|
+
end
|
112
|
+
end.yield_self { |t| t.truncate(1024, omission: "... (truncated, full length: #{t.length})") },
|
94
113
|
"",
|
114
|
+
|
95
115
|
"-- Request sent at --",
|
96
116
|
env.request_sent_at.strftime("%Y-%m-%d %H:%M:%S.%2N") + " UTC",
|
97
117
|
"",
|
118
|
+
|
98
119
|
"-- Response headers --",
|
99
|
-
|
120
|
+
if response_headers
|
121
|
+
::JSON.generate(response_headers)
|
122
|
+
else
|
123
|
+
env.response_headers.to_s
|
124
|
+
end.yield_self { |t| t.truncate(2048, omission: "... (truncated, full length: #{t.length})") },
|
100
125
|
"",
|
126
|
+
|
101
127
|
"-- Response body --",
|
102
|
-
|
128
|
+
if response_json
|
129
|
+
::JSON.generate(response_json)
|
130
|
+
else
|
131
|
+
body = env.body.to_s.dup
|
132
|
+
if body.encoding.name == "ASCII-8BIT"
|
133
|
+
"Binary (#{body.size} bytes)"
|
134
|
+
else
|
135
|
+
body
|
136
|
+
end
|
137
|
+
end.yield_self { |t| t.truncate(2048, omission: "... (truncated, full length: #{t.length})") }
|
103
138
|
]
|
104
139
|
|
105
140
|
if env.response_received_at
|
@@ -113,7 +148,7 @@ module Faraday
|
|
113
148
|
]
|
114
149
|
end
|
115
150
|
|
116
|
-
lines.join("\n")
|
151
|
+
lines.join("\n") + "\n"
|
117
152
|
end
|
118
153
|
|
119
154
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better-faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|