http-form_data 2.1.1 → 2.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 +5 -5
- data/.editorconfig +9 -0
- data/.gitignore +1 -0
- data/.travis.yml +6 -5
- data/CHANGES.md +7 -0
- data/README.md +3 -3
- data/http-form_data.gemspec +0 -2
- data/lib/http/form_data/composite_io.rb +28 -15
- data/lib/http/form_data/version.rb +1 -1
- data/spec/lib/http/form_data/multipart_spec.rb +2 -2
- data/spec/lib/http/form_data/part_spec.rb +1 -1
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e09c6384f02137e31adab5115524beb33decdf03cff1e52b6e37f660a5956256
|
4
|
+
data.tar.gz: 5a2e181da1de4da73edb2be5d970b9ad4afbe2f2c9edcc8421ba3c885908f7a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade103ecd25eb756f92421d673ab68af8629c40ed6b2633af6cdf0d5173c4a9332aa7bf33970c85e2b1926ee5c4b3d2dc0d33f4eaa506512b36da398e9a4b402
|
7
|
+
data.tar.gz: d89facbae50f67e1fb8f08b4395e37b6477a21c5d83bbe4efcebef488204020f100ef525e5141fbfa7186e905815662c8093a90b576ac8d19b3976c5e1d1da3a
|
data/.editorconfig
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -6,7 +6,7 @@ cache: bundler
|
|
6
6
|
before_install:
|
7
7
|
- gem update --system
|
8
8
|
- gem --version
|
9
|
-
- gem install bundler --no-
|
9
|
+
- gem install bundler --no-document
|
10
10
|
- bundle --version
|
11
11
|
|
12
12
|
install: bundle install --without development doc
|
@@ -18,14 +18,15 @@ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
|
18
18
|
rvm:
|
19
19
|
# Include JRuby first because it takes the longest
|
20
20
|
- jruby-9.1.13.0
|
21
|
-
- 2.
|
22
|
-
- 2.
|
23
|
-
- 2.
|
21
|
+
- 2.4
|
22
|
+
- 2.5
|
23
|
+
- 2.6
|
24
|
+
- 2.7
|
24
25
|
|
25
26
|
matrix:
|
26
27
|
fast_finish: true
|
27
28
|
include:
|
28
|
-
- rvm: 2.
|
29
|
+
- rvm: 2.7
|
29
30
|
env: SUITE="rubocop"
|
30
31
|
|
31
32
|
branches:
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -58,10 +58,10 @@ form = HTTP::FormData.create({
|
|
58
58
|
This library aims to support and is [tested against][ci] the following Ruby
|
59
59
|
versions:
|
60
60
|
|
61
|
-
* Ruby 2.1.x
|
62
|
-
* Ruby 2.2.x
|
63
|
-
* Ruby 2.3.x
|
64
61
|
* Ruby 2.4.x
|
62
|
+
* Ruby 2.5.x
|
63
|
+
* Ruby 2.6.x
|
64
|
+
* Ruby 2.7.x
|
65
65
|
* JRuby 9.1.x.x
|
66
66
|
|
67
67
|
If something doesn't work on one of these versions, it's a bug.
|
data/http-form_data.gemspec
CHANGED
@@ -22,6 +22,4 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^bin\/}).map { |f| File.basename(f) }
|
23
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)\/})
|
24
24
|
spec.require_paths = ["lib"]
|
25
|
-
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
27
25
|
end
|
@@ -29,23 +29,12 @@ module HTTP
|
|
29
29
|
#
|
30
30
|
# @return [String, nil]
|
31
31
|
def read(length = nil, outbuf = nil)
|
32
|
-
|
33
|
-
|
34
|
-
outbuf.force_encoding(Encoding::BINARY)
|
32
|
+
data = outbuf.clear.force_encoding(Encoding::BINARY) if outbuf
|
33
|
+
data ||= "".b
|
35
34
|
|
36
|
-
|
37
|
-
current_io.read(length, @buffer)
|
38
|
-
outbuf << @buffer.force_encoding(Encoding::BINARY)
|
39
|
-
|
40
|
-
if length
|
41
|
-
length -= @buffer.bytesize
|
42
|
-
break if length.zero?
|
43
|
-
end
|
44
|
-
|
45
|
-
advance_io
|
46
|
-
end
|
35
|
+
read_chunks(length) { |chunk| data << chunk }
|
47
36
|
|
48
|
-
|
37
|
+
data unless length && data.empty?
|
49
38
|
end
|
50
39
|
|
51
40
|
# Returns sum of all IO sizes.
|
@@ -61,6 +50,30 @@ module HTTP
|
|
61
50
|
|
62
51
|
private
|
63
52
|
|
53
|
+
# Yields chunks with total length up to `length`.
|
54
|
+
def read_chunks(length = nil)
|
55
|
+
while (chunk = readpartial(length))
|
56
|
+
yield chunk.force_encoding(Encoding::BINARY)
|
57
|
+
|
58
|
+
next if length.nil?
|
59
|
+
|
60
|
+
length -= chunk.bytesize
|
61
|
+
|
62
|
+
break if length.zero?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Reads chunk from current IO with length up to `max_length`.
|
67
|
+
def readpartial(max_length = nil)
|
68
|
+
while current_io
|
69
|
+
chunk = current_io.read(max_length, @buffer)
|
70
|
+
|
71
|
+
return chunk if chunk && !chunk.empty?
|
72
|
+
|
73
|
+
advance_io
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
64
77
|
# Returns IO object under the cursor.
|
65
78
|
def current_io
|
66
79
|
@ios[@index]
|
@@ -57,7 +57,7 @@ RSpec.describe HTTP::FormData::Multipart do
|
|
57
57
|
|
58
58
|
context "with filename set to nil" do
|
59
59
|
let(:part) { HTTP::FormData::Part.new("s", :content_type => "mime/type") }
|
60
|
-
let(:form_data) { HTTP::FormData::Multipart.new(:foo => part) }
|
60
|
+
let(:form_data) { HTTP::FormData::Multipart.new({ :foo => part }) }
|
61
61
|
|
62
62
|
it "doesn't include a filename" do
|
63
63
|
boundary_value = form_data.content_type[/(#{boundary})$/, 1]
|
@@ -74,7 +74,7 @@ RSpec.describe HTTP::FormData::Multipart do
|
|
74
74
|
|
75
75
|
context "with content type set to nil" do
|
76
76
|
let(:part) { HTTP::FormData::Part.new("s") }
|
77
|
-
let(:form_data) { HTTP::FormData::Multipart.new(:foo => part) }
|
77
|
+
let(:form_data) { HTTP::FormData::Multipart.new({ :foo => part }) }
|
78
78
|
|
79
79
|
it "doesn't include a filename" do
|
80
80
|
boundary_value = form_data.content_type[/(#{boundary})$/, 1]
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-form_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksey V Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.7'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.7'
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Utility-belt to build form data request bodies. Provides support for
|
28
14
|
`application/x-www-form-urlencoded` and `multipart/form-data` types.
|
29
15
|
email:
|
@@ -32,6 +18,7 @@ executables: []
|
|
32
18
|
extensions: []
|
33
19
|
extra_rdoc_files: []
|
34
20
|
files:
|
21
|
+
- ".editorconfig"
|
35
22
|
- ".gitignore"
|
36
23
|
- ".rspec"
|
37
24
|
- ".rubocop.yml"
|
@@ -83,11 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
70
|
- !ruby/object:Gem::Version
|
84
71
|
version: '0'
|
85
72
|
requirements: []
|
86
|
-
|
87
|
-
rubygems_version: 2.6.14.1
|
73
|
+
rubygems_version: 3.1.2
|
88
74
|
signing_key:
|
89
75
|
specification_version: 4
|
90
|
-
summary: http-form_data-2.
|
76
|
+
summary: http-form_data-2.2.0
|
91
77
|
test_files:
|
92
78
|
- spec/fixtures/expected-multipart-body.tpl
|
93
79
|
- spec/fixtures/the-http-gem.info
|