pigeon-http 0.1.4 → 0.1.5
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/pigeon/core.rb +3 -4
- data/lib/pigeon/http.rb +11 -7
- data/lib/pigeon/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: 20b7eedde8b0c9fb75e25872962fbda47a2425927c94995bcf99b5d6b2515c23
|
4
|
+
data.tar.gz: 81d2864272ffb24191949f132fd53964548391d561cf7b00057bc916b1a56d56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3b66e8bb1b3f1acad749742d6759af5aa0ad2eaac4ec144fcb5f956a93a44cba79745e3331c12587fdeb2041adc9f454448b2de7cb421c698ddb52ac078711c
|
7
|
+
data.tar.gz: 39939f3c8160246dea3c00e3c992474b175e79b266b62aafc3bb3925257063baf842edc1118c8107c0ea0533ec50760cfb8dc68d81361f29f65bd6237287bcdb
|
data/Gemfile.lock
CHANGED
data/lib/pigeon/core.rb
CHANGED
@@ -79,7 +79,6 @@ module Pigeon
|
|
79
79
|
def get url, args = {}
|
80
80
|
response = http(:get, url, args)
|
81
81
|
rescue => e
|
82
|
-
puts e
|
83
82
|
@callbacks[:HttpError]&.call(e)
|
84
83
|
end
|
85
84
|
|
@@ -111,9 +110,9 @@ module Pigeon
|
|
111
110
|
response = Pigeon::Http::Request.new(method, url, args).execute
|
112
111
|
|
113
112
|
uri = URI.parse(url)
|
114
|
-
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: [uri.host]).capture(action: :histogram, count: (Time.now - start))
|
115
|
-
Pigeon::Statsd.new(@options[:request_name] + '_througput', tags: [uri.host]).capture
|
116
|
-
Pigeon::Statsd.new(@options[:request_name] + '_status', tags: [response.code]).capture
|
113
|
+
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: ["host:#{uri.host}"]).capture(action: :histogram, count: (Time.now - start))
|
114
|
+
Pigeon::Statsd.new(@options[:request_name] + '_througput', tags: ["host:#{uri.host}"]).capture
|
115
|
+
Pigeon::Statsd.new(@options[:request_name] + '_status', tags: ["host:#{uri.host}", "http:#{response.code}"]).capture
|
117
116
|
|
118
117
|
response
|
119
118
|
end
|
data/lib/pigeon/http.rb
CHANGED
@@ -17,7 +17,7 @@ module Pigeon
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Request
|
20
|
-
VALID_PARAMETERS = %w[headers query body auth timeout open_timeout ssl_timeout read_timeout max_redirects ssl_verify]
|
20
|
+
VALID_PARAMETERS = %w[headers query body form auth timeout open_timeout ssl_timeout read_timeout max_redirects ssl_verify]
|
21
21
|
DEFAULT_HEADERS = { 'User-Agent' => 'HTTP Client API/1.0' }
|
22
22
|
VALID_VERBS = [GET, HEAD, PUT, POST, DELETE, OPTIONS, TRACE]
|
23
23
|
VALID_SSL_VERIFICATIONS = [SSL_VERIFY_NONE, SSL_VERIFY_PEER]
|
@@ -81,24 +81,28 @@ module Pigeon
|
|
81
81
|
klass = find_delegate_class(verb)
|
82
82
|
headers = DEFAULT_HEADERS.merge(args.fetch(:headers, {}))
|
83
83
|
body = args[:body]&.to_json
|
84
|
+
form = args[:form]&.transform_keys(&:to_s)
|
84
85
|
query = args[:query]
|
85
86
|
uri = uri.dup
|
86
87
|
delegate = klass.new(uri, headers)
|
87
88
|
|
89
|
+
delegate.content_type = 'application/json'
|
90
|
+
|
88
91
|
if body
|
89
92
|
raise Error::Argument, "#{verb} cannot have body" unless klass.const_get(:REQUEST_HAS_BODY)
|
90
|
-
delegate.
|
91
|
-
|
93
|
+
delegate.body = body
|
94
|
+
elsif form
|
95
|
+
raise Error::Argument, "#{verb} cannot have form" unless klass.const_get(:REQUEST_HAS_BODY)
|
96
|
+
delegate.content_type = 'multipart/form-data'
|
97
|
+
delegate.set_form(form, 'multipart/form-data')
|
92
98
|
elsif query
|
93
99
|
if klass.const_get(:REQUEST_HAS_BODY)
|
94
|
-
delegate =
|
100
|
+
delegate.content_type = 'application/x-www-form-urlencoded'
|
95
101
|
delegate.set_form_data(query)
|
96
102
|
else
|
97
103
|
uri.query = URI.encode_www_form(query)
|
98
|
-
delegate
|
104
|
+
delegate = klass.new(uri, headers)
|
99
105
|
end
|
100
|
-
else
|
101
|
-
delegate = klass.new(uri, headers)
|
102
106
|
end
|
103
107
|
|
104
108
|
delegate
|
data/lib/pigeon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pigeon-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fitra Aditya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: circuitbox
|