pigeon-http 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204c0c65ca18699400c662cdce4813337fa5f270a15012c63279ab03e1fb35c4
4
- data.tar.gz: f2c2070ca2ab97182b0574ecf281759a14cee4b7d7d42f42ce23d97b8a8a0ace
3
+ metadata.gz: 20b7eedde8b0c9fb75e25872962fbda47a2425927c94995bcf99b5d6b2515c23
4
+ data.tar.gz: 81d2864272ffb24191949f132fd53964548391d561cf7b00057bc916b1a56d56
5
5
  SHA512:
6
- metadata.gz: 2f66c5ce34abe98064138ade62435d182a0592ee147799b52c199e19893f5b5c66dc01d5a3d7755efc7b9c330fb95d74e539d8176637b8fbda03b6baa31fce4a
7
- data.tar.gz: 72cc4bbac4814d99f6f3a79fdfe49a261cc65a7044706e8736469e61fb1b90ed5ca2edd07a47cc93f313c949bd7605b1f4982bfaf65990f08431b9a2b11dba58
6
+ metadata.gz: a3b66e8bb1b3f1acad749742d6759af5aa0ad2eaac4ec144fcb5f956a93a44cba79745e3331c12587fdeb2041adc9f454448b2de7cb421c698ddb52ac078711c
7
+ data.tar.gz: 39939f3c8160246dea3c00e3c992474b175e79b266b62aafc3bb3925257063baf842edc1118c8107c0ea0533ec50760cfb8dc68d81361f29f65bd6237287bcdb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pigeon-http (0.1.4)
4
+ pigeon-http (0.1.5)
5
5
  circuitbox
6
6
  ddtrace
7
7
  dogstatsd-ruby
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.content_type = 'application/json'
91
- delegate.body = body
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 = klass.new(uri, headers)
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 = klass.new(uri, headers)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pigeon
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
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
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-14 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: circuitbox