json_requester 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/json_requester.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a0dd5080d2bec29884d6da9cf56099973847d3ba0841f296089591278ce6b84
|
4
|
+
data.tar.gz: ac92413b55e07c14f48515ce0e62cfb5e990b701c8eb5ee2b3c7887cd9cdf124
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8103bb5bf91b6df2ddfb88558d4c8091beaf3893ce0a24d17a4a91f8dfcc99b0e7aecd73c0b65beac5c5e7e2d21ac6de4b5fe71fe9e6dc2ac3532a31ad66289e
|
7
|
+
data.tar.gz: e137988468f479c1e7a26d9a1aaacfe4e2d9935286b884fa42f6edd462e5dc283e94a2e980b9329cccc82c4e94f9ffbe5bbe2a5d140464b95a2b49f0ab57b2eb
|
data/README.md
CHANGED
@@ -30,7 +30,8 @@ $ gem install json_requester
|
|
30
30
|
# Request by using JSON body or query params, use the `http_send` method.
|
31
31
|
# other methods: `form_send`, `multipart_form_send`
|
32
32
|
# `sort_params` at Faraday gem default is true.
|
33
|
-
|
33
|
+
# `content_type_charset` default is 'utf-8', this will add ; charset=utf-8 after `Content-Type` header (ex. `Content-Type=application/json; charset=utf-8`).
|
34
|
+
res = requester.http_send(http_method, path, params, headers, sort_params: true, content_type_charset: 'utf-8')
|
34
35
|
|
35
36
|
# http response code
|
36
37
|
puts res['status'] # 200, 404, .. etc
|
data/lib/json_requester.rb
CHANGED
@@ -12,12 +12,12 @@ class JsonRequester
|
|
12
12
|
@user_agent = user_agent.strip.to_s
|
13
13
|
end
|
14
14
|
|
15
|
-
def http_send(http_method, path, params={}, headers={}, sort_params: true, need_response_header: false)
|
15
|
+
def http_send(http_method, path, params={}, headers={}, sort_params: true, need_response_header: false, content_type_charset: 'utf-8')
|
16
16
|
puts "send #{http_method} reqeust to #{@host} with\npath: #{path}\nparams: #{params}\nheaders: #{headers}"
|
17
17
|
if http_method == :get
|
18
18
|
normal_send(http_method, path, params, headers, sort_params: sort_params, need_response_header: need_response_header)
|
19
19
|
else
|
20
|
-
json_send(http_method, path, params, headers, sort_params: sort_params, need_response_header: need_response_header)
|
20
|
+
json_send(http_method, path, params, headers, sort_params: sort_params, need_response_header: need_response_header, content_type_charset: content_type_charset)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|