huginn_http_request_agent 1.1.1 → 1.2.0

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
  SHA1:
3
- metadata.gz: bec8062be1a834e003117e28147300943d2faf0c
4
- data.tar.gz: 83cd7b80899ad3c29814a43f7e0df12d610b88c2
3
+ metadata.gz: 653100f0a586c808cea718f38a8e55873b20666b
4
+ data.tar.gz: 610976e15c13270eaaea835188f0d93ecb6bbe29
5
5
  SHA512:
6
- metadata.gz: 59fe416d30b753c2d2b95b5d14ca6c3499d358f4cf10ec9ca570dcbaa215c70b4e8ea6d0dd480f783340faac5440858ef86ea86e1f67cd7c6b06ef7a9fb6ee4f
7
- data.tar.gz: 3d3b737bfccdf6e2d11f8e516fdf31306e812cb2288be327c94a6dc3cbe94736bbcfbc679baffec76351f1d408604fa5422c2e6c833eb6b10360ba24cfbf470a
6
+ metadata.gz: 9a8d6736777a825a9115d54532866c45e6657b38ce90beae9a317556f6485ebac898b33ed3503c7003c87307801dc62db1be047dcd4d17eacad6c13986aaa549
7
+ data.tar.gz: e88736b87e88e5602b3a081e1745887d7e63cc0d5b3d0fea56e91242c37432480396acab0e8079e4694d24eb2af7ab6b8bfa6a6f7060e431e05d7cc6ae5affab
@@ -42,11 +42,18 @@ module Agents
42
42
 
43
43
  - `json` to send JSON instead
44
44
  - `xml` to send XML, where the name of the root element may be specified using `xml_root`
45
+ - All other `content_type`'s will be serialized as a string
45
46
 
46
47
  By default, non-GETs will be sent with form encoding (`application/json`).
47
48
 
48
- When `content_type` contains a [MIME](https://en.wikipedia.org/wiki/Media_type) type, and `payload` is a string, its interpolated value will be sent as a string in the HTTP request's body and the request's `Content-Type` HTTP header will be set to `content_type`.
49
+ The `content_type` field will default the `Content-Type` header if it is not explicitly set in the following manner:
49
50
 
51
+ - if `Content-Type` is set use value
52
+ - else if `content_type==json` then `Content-Type=application/json`
53
+ - else if `content_type==xml` then `Content-Type=application/xml`
54
+ - else `Content-Type=content_type`
55
+
56
+ This allows you fine grained control over the mime type being used.
50
57
 
51
58
  ### Response
52
59
 
@@ -194,7 +201,7 @@ module Agents
194
201
 
195
202
  case content_type
196
203
  when 'json'
197
- headers['Content-Type'] = 'application/json; charset=utf-8'
204
+ headers['Content-Type'] ||= 'application/json; charset=utf-8'
198
205
  url = faraday.build_url(url, data.compact)
199
206
  else
200
207
  params = data
@@ -216,13 +223,13 @@ module Agents
216
223
 
217
224
  case content_type
218
225
  when 'json'
219
- headers['Content-Type'] = 'application/json; charset=utf-8'
226
+ headers['Content-Type'] ||= 'application/json; charset=utf-8'
220
227
  body = data.to_json
221
228
  when 'xml'
222
- headers['Content-Type'] = 'text/xml; charset=utf-8'
229
+ headers['Content-Type'] ||= 'text/xml; charset=utf-8'
223
230
  body = data.to_xml(root: (interpolated(event.payload)[:xml_root] || 'post'))
224
231
  when MIME_RE
225
- headers['Content-Type'] = content_type
232
+ headers['Content-Type'] ||= content_type
226
233
  body = data.to_s
227
234
  else
228
235
  body = data
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huginn_http_request_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Spizziri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2019-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler