mint_http 0.1.9 → 0.1.11

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: b0d6eb6fc74d83a79da5384f6ecec034ea2402752539ac29b40b43c85a0422a0
4
- data.tar.gz: 29ba4aa2fdd0f1bb3dfeccb44d83766ea1908d945318db6cf918127c39c5eea7
3
+ metadata.gz: 13d0c6552e8bbf4b2d407cfb63f912116332c050ef55ff2b40249e357eaf50b2
4
+ data.tar.gz: bb5ed66026c77894f50c1cb4f399e5cb6c4636213105ee2d6cd041c3718ab36c
5
5
  SHA512:
6
- metadata.gz: f0d28be37857d0943a281ff4469095e0a9cb6d58a67a47a14dd7290970564e39306bde41d772a00511136d7cf0a3fef2a202ea3d300e64c40a44b5bc2783079d
7
- data.tar.gz: f0c4050bb642956395b7ccf13279659ef73e23787304127b44c663e9153d48510151438bf4295d8c3e3eeb8e86f80548d0be695daeb8c36829863ae8b532455b
6
+ metadata.gz: c77b61d61e1268f799c2bfaf57d14fbea69255156c6b4b05c77df50df19bf188e4145134158a20876bbdea37a337a649fbd1253a3ff9c502a47e63b52219e63f
7
+ data.tar.gz: 101e27c0c4fcf208ce2eb80dbba3a5fa4d998937cf57db20d61ed76a94c4e8c0fc8ab42096c8f6d535bc1bba7b95990a895a8b5c308958dab4767b9333d3f1b9
@@ -165,7 +165,7 @@ module MintHttp
165
165
  end
166
166
 
167
167
  def accept_json
168
- accept('application/json')
168
+ accept('application/json; charset=utf-8')
169
169
  end
170
170
 
171
171
  def content_type(type)
@@ -185,7 +185,7 @@ module MintHttp
185
185
 
186
186
  def as_json
187
187
  @body_type = :json
188
- content_type('application/json')
188
+ content_type('application/json; charset=utf-8')
189
189
  end
190
190
 
191
191
  def as_form
@@ -79,7 +79,7 @@ module MintHttp
79
79
  tls = "#{@tls_config[:version]} Cipher: #{@tls_config[:cipher]}"
80
80
  end
81
81
 
82
- buffer = String.new
82
+ buffer = String.new(encoding: 'UTF-8')
83
83
  buffer << <<~TXT
84
84
  MintHttp Log (#{@request.request_url})
85
85
  @@ Timeouts: #{@request.open_timeout}, #{@request.write_timeout}, #{@request.read_timeout}
@@ -87,7 +87,7 @@ module MintHttp
87
87
  @@ TLS: #{tls}
88
88
  -> #{@request.method.upcase} #{path} HTTP/#{version}
89
89
  #{masked_headers(@net_request.each_header.to_h, '-> ')}
90
- -> #{masked_body(@request.body, @request.headers['content-type'])}
90
+ -> #{masked_body(@net_request.body, @request.headers['content-type'])}
91
91
  =======
92
92
  TXT
93
93
 
@@ -108,6 +108,8 @@ module MintHttp
108
108
  end
109
109
 
110
110
  @logger.info(buffer.strip)
111
+ rescue Encoding::CompatibilityError => e
112
+ logger.logger.warn(e)
111
113
  end
112
114
 
113
115
  def log_connection_info(http)
@@ -163,6 +165,8 @@ module MintHttp
163
165
  end
164
166
 
165
167
  def masked_body(body, type)
168
+ type ||= 'application/octet-stream'
169
+
166
170
  size = body&.bytesize || 0
167
171
  if size == 0
168
172
  return '[EMPTY]'
@@ -176,6 +180,9 @@ module MintHttp
176
180
  return '[COMPLEX]'
177
181
  end
178
182
 
183
+ # Force encoding to UTF-8 to allow logging
184
+ body = body.dup.force_encoding('utf-8')
185
+
179
186
  unless @filter
180
187
  return body
181
188
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MintHttp
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mint_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-20 00:00:00.000000000 Z
11
+ date: 2024-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.4.10
135
+ rubygems_version: 3.2.33
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: A small fluent HTTP client.