ethon 0.9.1 → 0.10.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 +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +5 -1
- data/lib/ethon/curls/options.rb +1 -1
- data/lib/ethon/easy/form.rb +2 -2
- data/lib/ethon/easy/header.rb +7 -1
- data/lib/ethon/version.rb +1 -1
- data/spec/ethon/easy/form_spec.rb +18 -0
- data/spec/ethon/easy/header_spec.rb +30 -0
- 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: 612df63c107484c065be684be2f9d9c0b228a371
|
4
|
+
data.tar.gz: 906f70fe6d048a0b3e8022ad24d704996c18bb90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 614883cb82bd35ffe340e9e2b9d091726d8345d8b293b2a4efbfaed7244b181c2657543dcc4824af8e2fc347b32029b2e84ac9069edc6c0e58d92191eda97dd9
|
7
|
+
data.tar.gz: 6bb002290d0e5ca932f2f90a79eb05d96942582fdff2cb6f86febfdfc932b8e6e48437716017cfd8e6e014a7fe765ec1f4259239023e461c211fbd823c109dcd
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/typhoeus/ethon/compare/v0.
|
5
|
+
[Full Changelog](https://github.com/typhoeus/ethon/compare/v0.10.0...master)
|
6
|
+
|
7
|
+
## 0.10.0
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/typhoeus/ethon/compare/v0.9.1...v0.10.0)
|
6
10
|
|
7
11
|
## 0.9.1
|
8
12
|
|
data/lib/ethon/curls/options.rb
CHANGED
@@ -335,7 +335,7 @@ module Ethon
|
|
335
335
|
option :easy, :cookiesession, :bool, 96
|
336
336
|
option :easy, :cookielist, :string, 135
|
337
337
|
option :easy, :httpget, :bool, 80
|
338
|
-
option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1]
|
338
|
+
option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1, :httpv2_0]
|
339
339
|
option :easy, :ignore_content_length, :bool, 136
|
340
340
|
option :easy, :http_content_decoding, :bool, 158
|
341
341
|
option :easy, :http_transfer_decoding, :bool, 157
|
data/lib/ethon/easy/form.rb
CHANGED
@@ -82,8 +82,8 @@ module Ethon
|
|
82
82
|
Curl.formadd(first, last,
|
83
83
|
:form_option, :copyname, :pointer, name,
|
84
84
|
:form_option, :namelength, :long, name.bytesize,
|
85
|
-
:form_option, :copycontents, :pointer, content,
|
86
|
-
:form_option, :contentslength, :long, content ? content.bytesize : 0,
|
85
|
+
:form_option, :copycontents, :pointer, content.to_s,
|
86
|
+
:form_option, :contentslength, :long, content ? content.to_s.bytesize : 0,
|
87
87
|
:form_option, :end
|
88
88
|
)
|
89
89
|
end
|
data/lib/ethon/easy/header.rb
CHANGED
@@ -4,6 +4,8 @@ module Ethon
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
module Header
|
7
|
+
EMPTY_STRING_VALUE = "".freeze
|
8
|
+
|
7
9
|
# Return headers, return empty hash if none.
|
8
10
|
#
|
9
11
|
# @example Return the headers.
|
@@ -53,7 +55,11 @@ module Ethon
|
|
53
55
|
#
|
54
56
|
# @return [ String ] The composed header.
|
55
57
|
def compose_header(key, value)
|
56
|
-
|
58
|
+
if(value == EMPTY_STRING_VALUE)
|
59
|
+
Util.escape_zero_byte("#{key};")
|
60
|
+
else
|
61
|
+
Util.escape_zero_byte("#{key}: #{value}")
|
62
|
+
end
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
data/lib/ethon/version.rb
CHANGED
@@ -72,5 +72,23 @@ describe Ethon::Easy::Form do
|
|
72
72
|
form.materialize
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
context "when query_pairs contains file and string values" do
|
77
|
+
let(:pairs) { [['a', ["file", "type", "path/file"]], ['b', '1']] }
|
78
|
+
|
79
|
+
it "adds file to form" do
|
80
|
+
expect(Ethon::Curl).to receive(:formadd).twice
|
81
|
+
form.materialize
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when query_pairs contains file, string and int values" do
|
86
|
+
let(:pairs) { [['a', ["file", "type", "path/file"]], ['b', '1'], ['c', 1]] }
|
87
|
+
|
88
|
+
it "adds file to form" do
|
89
|
+
expect(Ethon::Curl).to receive(:formadd).exactly(3).times
|
90
|
+
form.materialize
|
91
|
+
end
|
92
|
+
end
|
75
93
|
end
|
76
94
|
end
|
@@ -46,6 +46,36 @@ describe Ethon::Easy::Header do
|
|
46
46
|
expect(easy.response_body).to include('"HTTP_USER_AGENT":"Ethon"')
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
context "when header value is empty string" do
|
51
|
+
let(:headers) { { 'User-Agent' => "" } }
|
52
|
+
|
53
|
+
if(Ethon::Curl.version_info[:version] >= "7.23.0")
|
54
|
+
it "sends header with empty value" do
|
55
|
+
expect(easy.response_body).to include('"HTTP_USER_AGENT":""')
|
56
|
+
end
|
57
|
+
else
|
58
|
+
it "does not send header (curl < 7.23.0 does not support empty values)" do
|
59
|
+
expect(easy.response_body).to_not include('"HTTP_USER_AGENT"')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when header value is nil" do
|
65
|
+
let(:headers) { { 'User-Agent' => nil } }
|
66
|
+
|
67
|
+
it "does not send header" do
|
68
|
+
expect(easy.response_body).to_not include('"HTTP_USER_AGENT"')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when header value is integer" do
|
73
|
+
let(:headers) { { 'User-Agent' => 0 } }
|
74
|
+
|
75
|
+
it "sends as string" do
|
76
|
+
expect(easy.response_body).to include('"HTTP_USER_AGENT":"0"')
|
77
|
+
end
|
78
|
+
end
|
49
79
|
end
|
50
80
|
end
|
51
81
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hans Hasselberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|