nethttputils 0.2.2.0 → 0.2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/lib/nethttputils.rb +14 -8
- data/nethttputils.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bec88b8ff9beeae7cc18250b6a2d955aa6d7845b
|
4
|
+
data.tar.gz: 820c5f45fbd937fd89912eb30c35c264f98923df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5d9ab8603996adc703bb812d85fea42e359167736be39eecdd1aecc71d8c1667662672b8cb22ce7ff66384b655415aa342b4b0b0f005d3a5a7e09359074df88
|
7
|
+
data.tar.gz: 6ebc04827c686dfc8e15f9cdb14758ef5604a45e252e2472da070603dacb779a92f2ff11d5869b6b1d7bd64f9d4bb049b66dd69ddbbdc5bf91730e9a87877814
|
data/.travis.yml
CHANGED
data/lib/nethttputils.rb
CHANGED
@@ -35,9 +35,10 @@ module NetHTTPUtils
|
|
35
35
|
url
|
36
36
|
rescue URI::InvalidURIError
|
37
37
|
URI.escape url
|
38
|
-
end
|
38
|
+
end unless uri.is_a? URI::HTTP
|
39
|
+
|
39
40
|
|
40
|
-
logger.warn "Warning: query params included `url` are discarded because `:form` isn't empty" if uri.query && !form.empty?
|
41
|
+
logger.warn "Warning: query params included in `url` argument are discarded because `:form` isn't empty" if uri.query && !form.empty?
|
41
42
|
# we can't just merge because URI fails to parse such queries as "/?1"
|
42
43
|
|
43
44
|
uri.query = URI.encode_www_form form if :GET == (mtd = mtd.upcase) && !form.empty?
|
@@ -54,12 +55,17 @@ module NetHTTPUtils
|
|
54
55
|
patch_request.call uri, form, request if patch_request
|
55
56
|
request.basic_auth *auth if auth
|
56
57
|
request["cookie"] = [*request["cookie"], cookies.map{ |k, v| "#{k}=#{v}" }].join "; " unless cookies.empty?
|
57
|
-
|
58
|
-
if mtd == :POST || mtd == :PATCH
|
59
|
-
|
60
|
-
when :form ;
|
61
|
-
|
62
|
-
|
58
|
+
# pp Object.instance_method(:method).bind(request).call(:set_form).source_location
|
59
|
+
if (mtd == :POST || mtd == :PATCH) && !form.empty?
|
60
|
+
case type
|
61
|
+
when :form ; if form.any?{ |k, v| v.respond_to? :to_path }
|
62
|
+
request.set_form form, "multipart/form-data"
|
63
|
+
else
|
64
|
+
request.set_form_data form
|
65
|
+
request.content_type = "application/x-www-form-urlencoded;charset=UTF-8"
|
66
|
+
end
|
67
|
+
when :json ; request.body = JSON.dump form
|
68
|
+
request.content_type = "application/json"
|
63
69
|
else ; raise "unknown content-type '#{type}'"
|
64
70
|
end
|
65
71
|
end
|
data/nethttputils.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "nethttputils"
|
3
|
-
spec.version = "0.2.
|
3
|
+
spec.version = "0.2.3.0"
|
4
4
|
spec.summary = "this tool is like a pet that I adopted young and now I depend on, sorry"
|
5
5
|
spec.description = <<-EOF
|
6
6
|
Back in 2015 I was a guy automating things at my job and two scripts had a common need --
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nethttputils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov aka Nakilon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Back in 2015 I was a guy automating things at my job and two scripts had a common need --
|