multipart-post 2.2.3 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/changelog.md +14 -0
- data/lib/composite_io.rb +15 -0
- data/lib/multipart/post/composite_read_io.rb +32 -19
- data/lib/multipart/post/multipartable.rb +14 -30
- data/lib/multipart/post/parts.rb +18 -22
- data/lib/multipart/post/upload_io.rb +2 -19
- data/lib/multipart/post/version.rb +4 -20
- data/lib/multipart/post.rb +3 -19
- data/lib/multipart_post.rb +8 -0
- data/lib/multipartable.rb +17 -0
- data/lib/net/http/post/multipart.rb +6 -19
- data/lib/parts.rb +23 -0
- data/license.md +58 -0
- data/readme.md +170 -0
- data.tar.gz.sig +0 -0
- metadata +42 -62
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1a97f42595e55e76cf1f115f5ffb78f95e9c36f989d071dbe3c96334e2b159
|
4
|
+
data.tar.gz: fd4caef26f7fce4698034f9c2812f3c7e18ff3b1358ac2cfb8b7a3313eb01c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202d4172f8c99a3eda1e8a6d988ec4295d5ca14a4ce78e026f1d9f453e7ef176bf9ef362646ce660c6d79e17197c172637e43ae8f380106d62c944cf8234fffc
|
7
|
+
data.tar.gz: 77eb98a13d3afe0f20978fda9bf9c08be6c6e3edd4b3ede1ab2acf9e7780080bb1d146e229cc6413abdfe0f9bb46c6e72c4c96a4f81f1e2341335e360b3c427c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/changelog.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Add the ability to set Content-ID header for ParamPart [#62](https://github.com/socketry/multipart-post/pull/62)
|
8
|
+
- Allow mixed key types for parts headers [#79](https://github.com/socketry/multipart-post/pull/79)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Refactor `Parts` into a `Multipart::Post` namespace [#65](https://github.com/socketry/multipart-post/pull/65)
|
13
|
+
- Use mutable strings where needed [#70](https://github.com/socketry/multipart-post/pull/70)
|
14
|
+
- Use `frozen_string_literal` everywhere [#78](https://github.com/socketry/multipart-post/pull/78)
|
data/lib/composite_io.rb
CHANGED
@@ -1,2 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2006-2013, by Nick Sieger.
|
5
|
+
# Copyright, 2010, by Tohru Hashimoto.
|
6
|
+
# Copyright, 2011, by Jeff Hodges.
|
7
|
+
# Copyright, 2011, by Alex Koppel.
|
8
|
+
# Copyright, 2011, by Christine Yen.
|
9
|
+
# Copyright, 2011, by Gerrit Riessen.
|
10
|
+
# Copyright, 2011, by Luke Redpath.
|
11
|
+
# Copyright, 2013, by Mislav Marohnić.
|
12
|
+
# Copyright, 2013, by Leo Cassarani.
|
13
|
+
# Copyright, 2019, by Olle Jonsson.
|
14
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
15
|
+
|
1
16
|
warn "Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!"
|
2
17
|
require_relative 'multipart/post'
|
@@ -1,24 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2006-2013, by Nick Sieger.
|
5
|
+
# Copyright, 2010, by Tohru Hashimoto.
|
6
|
+
# Copyright, 2011, by Jeff Hodges.
|
7
|
+
# Copyright, 2011, by Alex Koppel.
|
8
|
+
# Copyright, 2011, by Christine Yen.
|
9
|
+
# Copyright, 2011, by Gerrit Riessen.
|
10
|
+
# Copyright, 2011, by Luke Redpath.
|
11
|
+
# Copyright, 2013, by Mislav Marohnić.
|
12
|
+
# Copyright, 2013, by Leo Cassarani.
|
13
|
+
# Copyright, 2019, by Olle Jonsson.
|
14
|
+
# Copyright, 2019, by Patrick Davey.
|
15
|
+
# Copyright, 2021, by Lewis Cowles.
|
16
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
22
17
|
|
23
18
|
module Multipart
|
24
19
|
module Post
|
@@ -38,8 +33,26 @@ module Multipart
|
|
38
33
|
@index = 0
|
39
34
|
end
|
40
35
|
|
36
|
+
# Close all the underyling IOs.
|
37
|
+
def close
|
38
|
+
@ios.each do |io|
|
39
|
+
io.close if io.respond_to?(:close)
|
40
|
+
end
|
41
|
+
|
42
|
+
@ios = nil
|
43
|
+
@index = 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def closed?
|
47
|
+
@ios.nil?
|
48
|
+
end
|
49
|
+
|
41
50
|
# Read from IOs in order until `length` bytes have been received.
|
42
51
|
def read(length = nil, outbuf = nil)
|
52
|
+
if @ios.nil?
|
53
|
+
raise IOError, "CompositeReadIO is closed!"
|
54
|
+
end
|
55
|
+
|
43
56
|
got_result = false
|
44
57
|
outbuf = outbuf ? outbuf.replace("") : String.new
|
45
58
|
|
@@ -1,24 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008, by McClain Looney.
|
5
|
+
# Copyright, 2008-2013, by Nick Sieger.
|
6
|
+
# Copyright, 2011, by Gerrit Riessen.
|
7
|
+
# Copyright, 2013, by Vincent Pellé.
|
8
|
+
# Copyright, 2013, by Gustav Ernberg.
|
9
|
+
# Copyright, 2013, by Socrates Vicente.
|
10
|
+
# Copyright, 2013, by Steffen Grunwald.
|
11
|
+
# Copyright, 2019, by Olle Jonsson.
|
12
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
13
|
+
# Copyright, 2019, by Patrick Davey.
|
14
|
+
# Copyright, 2022, by Jason York.
|
22
15
|
|
23
16
|
require_relative 'parts'
|
24
17
|
require_relative 'composite_read_io'
|
@@ -69,18 +62,9 @@ module Multipart
|
|
69
62
|
|
70
63
|
private
|
71
64
|
|
72
|
-
|
73
|
-
|
74
|
-
hash.transform_keys(&:to_sym)
|
75
|
-
end
|
76
|
-
else
|
77
|
-
def symbolize_keys(hash)
|
78
|
-
hash.map{|key,value| [key.to_sym, value]}.to_h
|
79
|
-
end
|
65
|
+
def symbolize_keys(hash)
|
66
|
+
hash.transform_keys(&:to_sym)
|
80
67
|
end
|
81
68
|
end
|
82
69
|
end
|
83
70
|
end
|
84
|
-
|
85
|
-
Multipartable = Multipart::Post::Multipartable
|
86
|
-
Object.deprecate_constant :Multipartable
|
data/lib/multipart/post/parts.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2009, by McClain Looney.
|
5
|
+
# Copyright, 2009-2013, by Nick Sieger.
|
6
|
+
# Copyright, 2011, by Johannes Wagener.
|
7
|
+
# Copyright, 2011, by Gerrit Riessen.
|
8
|
+
# Copyright, 2011, by Jason Moore.
|
9
|
+
# Copyright, 2012, by Steven Davidovitz.
|
10
|
+
# Copyright, 2012, by hexfet.
|
11
|
+
# Copyright, 2013, by Vincent Pellé.
|
12
|
+
# Copyright, 2013, by Gustav Ernberg.
|
13
|
+
# Copyright, 2013, by Socrates Vicente.
|
14
|
+
# Copyright, 2017, by David Moles.
|
15
|
+
# Copyright, 2017, by Matt Colyer.
|
16
|
+
# Copyright, 2017, by Eric Hutzelman.
|
17
|
+
# Copyright, 2019-2021, by Olle Jonsson.
|
18
|
+
# Copyright, 2019, by Ethan Turkeltaub.
|
19
|
+
# Copyright, 2019, by Patrick Davey.
|
20
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
22
21
|
|
23
22
|
require 'stringio'
|
24
23
|
|
@@ -147,6 +146,3 @@ module Multipart
|
|
147
146
|
end
|
148
147
|
end
|
149
148
|
end
|
150
|
-
|
151
|
-
Parts = Multipart::Post::Parts
|
152
|
-
Object.deprecate_constant :Parts
|
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
22
5
|
|
23
6
|
module Multipart
|
24
7
|
module Post
|
@@ -1,27 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019, by Patrick Davey.
|
5
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
22
6
|
|
23
7
|
module Multipart
|
24
8
|
module Post
|
25
|
-
VERSION = "2.
|
9
|
+
VERSION = "2.4.1"
|
26
10
|
end
|
27
11
|
end
|
data/lib/multipart/post.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019, by Patrick Davey.
|
5
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
22
6
|
|
23
7
|
require_relative 'post/multipartable'
|
24
8
|
require_relative 'post/upload_io'
|
data/lib/multipart_post.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2009-2013, by Nick Sieger.
|
5
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
6
|
+
|
1
7
|
warn "Top level ::MultipartPost is deprecated, require 'multipart/post' and use `Multipart::Post` instead!"
|
2
8
|
require_relative 'multipart/post'
|
9
|
+
|
3
10
|
MultipartPost = Multipart::Post
|
11
|
+
Object.deprecate_constant :MultipartPost
|
data/lib/multipartable.rb
CHANGED
@@ -1,2 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008, by McClain Looney.
|
5
|
+
# Copyright, 2008-2013, by Nick Sieger.
|
6
|
+
# Copyright, 2011, by Gerrit Riessen.
|
7
|
+
# Copyright, 2013, by Vincent Pellé.
|
8
|
+
# Copyright, 2013, by Gustav Ernberg.
|
9
|
+
# Copyright, 2013, by Socrates Vicente.
|
10
|
+
# Copyright, 2013, by Steffen Grunwald.
|
11
|
+
# Copyright, 2019, by Olle Jonsson.
|
12
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
13
|
+
# Copyright, 2019, by Patrick Davey.
|
14
|
+
|
1
15
|
warn "Top level ::Multipartable is deprecated, require 'multipart/post' and use `Multipart::Post::Multipartable` instead!"
|
2
16
|
require_relative 'multipart/post'
|
17
|
+
|
18
|
+
Multipartable = Multipart::Post::Multipartable
|
19
|
+
Object.deprecate_constant :Multipartable
|
@@ -1,24 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2006-2012, by Nick Sieger.
|
5
|
+
# Copyright, 2008, by McClain Looney.
|
6
|
+
# Copyright, 2019, by Olle Jonsson.
|
7
|
+
# Copyright, 2019, by Patrick Davey.
|
8
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
22
9
|
|
23
10
|
require 'net/http'
|
24
11
|
|
data/lib/parts.rb
CHANGED
@@ -1,2 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2008-2009, by McClain Looney.
|
5
|
+
# Copyright, 2009-2013, by Nick Sieger.
|
6
|
+
# Copyright, 2011, by Johannes Wagener.
|
7
|
+
# Copyright, 2011, by Gerrit Riessen.
|
8
|
+
# Copyright, 2011, by Jason Moore.
|
9
|
+
# Copyright, 2012, by Steven Davidovitz.
|
10
|
+
# Copyright, 2012, by hexfet.
|
11
|
+
# Copyright, 2013, by Vincent Pellé.
|
12
|
+
# Copyright, 2013, by Gustav Ernberg.
|
13
|
+
# Copyright, 2013, by Socrates Vicente.
|
14
|
+
# Copyright, 2017, by David Moles.
|
15
|
+
# Copyright, 2017, by Matt Colyer.
|
16
|
+
# Copyright, 2017, by Eric Hutzelman.
|
17
|
+
# Copyright, 2019, by Olle Jonsson.
|
18
|
+
# Copyright, 2019, by Ethan Turkeltaub.
|
19
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
20
|
+
|
1
21
|
warn "Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!"
|
2
22
|
require_relative 'multipart/post'
|
23
|
+
|
24
|
+
Parts = Multipart::Post::Parts
|
25
|
+
Object.deprecate_constant :Parts
|
data/license.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2006-2014, by Nick Sieger.
|
4
|
+
Copyright, 2008-2009, by McClain Looney.
|
5
|
+
Copyright, 2010, by Tohru Hashimoto.
|
6
|
+
Copyright, 2011, by Jeff Hodges.
|
7
|
+
Copyright, 2011, by Alex Koppel.
|
8
|
+
Copyright, 2011, by Johannes Wagener.
|
9
|
+
Copyright, 2011, by Christine Yen.
|
10
|
+
Copyright, 2011, by Gerrit Riessen.
|
11
|
+
Copyright, 2011, by Jason Moore.
|
12
|
+
Copyright, 2011, by Luke Redpath.
|
13
|
+
Copyright, 2012, by Steven Davidovitz.
|
14
|
+
Copyright, 2012, by hexfet.
|
15
|
+
Copyright, 2013, by Jordi Massaguer Pla.
|
16
|
+
Copyright, 2013, by Mislav Marohnić.
|
17
|
+
Copyright, 2013, by Vincent Pellé.
|
18
|
+
Copyright, 2013, by Gustav Ernberg.
|
19
|
+
Copyright, 2013, by Socrates Vicente.
|
20
|
+
Copyright, 2013, by Leo Cassarani.
|
21
|
+
Copyright, 2013, by Jagtesh Chadha.
|
22
|
+
Copyright, 2013, by Steffen Grunwald.
|
23
|
+
Copyright, 2013, by Lonre Wang.
|
24
|
+
Copyright, 2017-2024, by Samuel Williams.
|
25
|
+
Copyright, 2017, by Feuda Nan.
|
26
|
+
Copyright, 2017, by David Moles.
|
27
|
+
Copyright, 2017, by Matt Colyer.
|
28
|
+
Copyright, 2017, by Eric Hutzelman.
|
29
|
+
Copyright, 2019, by Lachlan Priest.
|
30
|
+
Copyright, 2019, by Jan Piotrowski.
|
31
|
+
Copyright, 2019-2022, by Olle Jonsson.
|
32
|
+
Copyright, 2019, by Ethan Turkeltaub.
|
33
|
+
Copyright, 2019, by Jan-Joost Spanjers.
|
34
|
+
Copyright, 2019, by Patrick Davey.
|
35
|
+
Copyright, 2021, by Tim Barkley.
|
36
|
+
Copyright, 2021, by Lewis Cowles.
|
37
|
+
Copyright, 2022, by Jason York.
|
38
|
+
Copyright, 2022, by Takuya Noguchi.
|
39
|
+
Copyright, 2023, by Peter Goldstein.
|
40
|
+
Copyright, 2024, by Masato Nakamura.
|
41
|
+
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
43
|
+
of this software and associated documentation files (the "Software"), to deal
|
44
|
+
in the Software without restriction, including without limitation the rights
|
45
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
46
|
+
copies of the Software, and to permit persons to whom the Software is
|
47
|
+
furnished to do so, subject to the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be included in all
|
50
|
+
copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
53
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
54
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
55
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
56
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
57
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
58
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# Multipart::Post
|
2
|
+
|
3
|
+
Adds a streamy multipart form post capability to `Net::HTTP`. Also supports other
|
4
|
+
methods besides `POST`.
|
5
|
+
|
6
|
+
[![Development Status](https://github.com/socketry/multipart-post/workflows/Test/badge.svg)](https://github.com/socketry/multipart-post/actions?workflow=Test)
|
7
|
+
|
8
|
+
## Features/Problems
|
9
|
+
|
10
|
+
- Appears to actually work. A good feature to have.
|
11
|
+
- Encapsulates posting of file/binary parts and name/value parameter parts, similar to
|
12
|
+
most browsers' file upload forms.
|
13
|
+
- Provides an `UploadIO` helper class to prepare IO objects for inclusion in the params
|
14
|
+
hash of the multipart post object.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
``` shell
|
19
|
+
bundle add multipart-post
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
``` ruby
|
25
|
+
require 'net/http/post/multipart'
|
26
|
+
|
27
|
+
url = URI.parse('http://www.example.com/upload')
|
28
|
+
File.open("./image.jpg") do |jpg|
|
29
|
+
req = Net::HTTP::Post::Multipart.new url.path,
|
30
|
+
"file" => UploadIO.new(jpg, "image/jpeg", "image.jpg")
|
31
|
+
res = Net::HTTP.start(url.host, url.port) do |http|
|
32
|
+
http.request(req)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
To post multiple files or attachments, simply include multiple parameters with
|
38
|
+
`UploadIO` values:
|
39
|
+
|
40
|
+
``` ruby
|
41
|
+
require 'net/http/post/multipart'
|
42
|
+
|
43
|
+
url = URI.parse('http://www.example.com/upload')
|
44
|
+
req = Net::HTTP::Post::Multipart.new url.path,
|
45
|
+
"file1" => UploadIO.new(File.new("./image.jpg"), "image/jpeg", "image.jpg"),
|
46
|
+
"file2" => UploadIO.new(File.new("./image2.jpg"), "image/jpeg", "image2.jpg")
|
47
|
+
res = Net::HTTP.start(url.host, url.port) do |http|
|
48
|
+
http.request(req)
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
To post files with other normal, non-file params such as input values, you need to pass hashes to the `Multipart.new` method.
|
53
|
+
|
54
|
+
In Rails 4 for example:
|
55
|
+
|
56
|
+
``` ruby
|
57
|
+
def model_params
|
58
|
+
require_params = params.require(:model).permit(:param_one, :param_two, :param_three, :avatar)
|
59
|
+
require_params[:avatar] = model_params[:avatar].present? ? UploadIO.new(model_params[:avatar].tempfile, model_params[:avatar].content_type, model_params[:avatar].original_filename) : nil
|
60
|
+
require_params
|
61
|
+
end
|
62
|
+
|
63
|
+
require 'net/http/post/multipart'
|
64
|
+
|
65
|
+
url = URI.parse('http://www.example.com/upload')
|
66
|
+
Net::HTTP.start(url.host, url.port) do |http|
|
67
|
+
req = Net::HTTP::Post::Multipart.new(url, model_params)
|
68
|
+
key = "authorization_key"
|
69
|
+
req.add_field("Authorization", key) #add to Headers
|
70
|
+
http.use_ssl = (url.scheme == "https")
|
71
|
+
http.request(req)
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
Or in plain ruby:
|
76
|
+
|
77
|
+
``` ruby
|
78
|
+
def params(file)
|
79
|
+
params = { "description" => "A nice picture!" }
|
80
|
+
params[:datei] = UploadIO.new(file, "image/jpeg", "image.jpg")
|
81
|
+
params
|
82
|
+
end
|
83
|
+
|
84
|
+
url = URI.parse('http://www.example.com/upload')
|
85
|
+
File.open("./image.jpg") do |file|
|
86
|
+
req = Net::HTTP::Post::Multipart.new(url.path, params(file))
|
87
|
+
res = Net::HTTP.start(url.host, url.port) do |http|
|
88
|
+
return http.request(req).body
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
### Parts Headers
|
94
|
+
|
95
|
+
By default, all individual parts will include the header `Content-Disposition` as well as `Content-Length`, `Content-Transfer-Encoding` and `Content-Type` for the File Parts.
|
96
|
+
|
97
|
+
You may optionally configure the headers `Content-Type` and `Content-ID` for both ParamPart and FilePart by passing in a `parts` header.
|
98
|
+
|
99
|
+
For example:
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
url = URI.parse('http://www.example.com/upload')
|
103
|
+
|
104
|
+
params = {
|
105
|
+
"file_metadata_01" => { "description" => "A nice picture!" },
|
106
|
+
"file_content_01" => UploadIO.new(file, "image/jpeg", "image.jpg")
|
107
|
+
}
|
108
|
+
|
109
|
+
headers = {
|
110
|
+
'parts': {
|
111
|
+
'file_metadata_01': {
|
112
|
+
'Content-Type' => "application/json"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
req = Net::HTTP::Post::Multipart.new(uri, params, headers)
|
118
|
+
```
|
119
|
+
|
120
|
+
This would configure the `file_metadata_01` part to include `Content-Type`
|
121
|
+
|
122
|
+
Content-Disposition: form-data; name="file_metadata_01"
|
123
|
+
Content-Type: application/json
|
124
|
+
{
|
125
|
+
"description" => "A nice picture!"
|
126
|
+
}
|
127
|
+
|
128
|
+
#### Custom Parts Headers
|
129
|
+
|
130
|
+
*For FileParts only.*
|
131
|
+
|
132
|
+
You can include any number of custom parts headers in addition to `Content-Type` and `Content-ID`.
|
133
|
+
|
134
|
+
``` ruby
|
135
|
+
headers = {
|
136
|
+
'parts': {
|
137
|
+
'file_metadata_01': {
|
138
|
+
'Content-Type' => "application/json",
|
139
|
+
'My-Custom-Header' => "Yo Yo!"
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
```
|
144
|
+
|
145
|
+
### Debugging
|
146
|
+
|
147
|
+
You can debug requests and responses (e.g. status codes) for all requests by adding the following code:
|
148
|
+
|
149
|
+
``` ruby
|
150
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
151
|
+
http.set_debug_output($stdout)
|
152
|
+
```
|
153
|
+
|
154
|
+
## Versioning
|
155
|
+
|
156
|
+
This library aims to adhere to [Semantic Versioning 2.0.0](http://semver.org/).
|
157
|
+
Violations of this scheme should be reported as bugs. Specifically,
|
158
|
+
if a minor or patch version is released that breaks backward
|
159
|
+
compatibility, a new version should be immediately released that
|
160
|
+
restores compatibility. Breaking changes to the public API will
|
161
|
+
only be introduced with new major versions.
|
162
|
+
|
163
|
+
As a result of this policy, you can (and should) specify a
|
164
|
+
dependency on this gem using the [Pessimistic Version Constraint](http://guides.rubygems.org/patterns/#pessimistic-version-constraint) with two digits of precision.
|
165
|
+
|
166
|
+
For example:
|
167
|
+
|
168
|
+
``` ruby
|
169
|
+
spec.add_dependency 'multipart-post', '~> 2.1'
|
170
|
+
```
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multipart-post
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sieger
|
@@ -16,9 +16,8 @@ authors:
|
|
16
16
|
- Ethan Turkeltaub
|
17
17
|
- Jagtesh Chadha
|
18
18
|
- Jason York
|
19
|
-
-
|
20
|
-
-
|
21
|
-
- hasimo
|
19
|
+
- Tohru Hashimoto
|
20
|
+
- Vincent Pellé
|
22
21
|
- hexfet
|
23
22
|
- Christine Yen
|
24
23
|
- David Moles
|
@@ -35,78 +34,55 @@ authors:
|
|
35
34
|
- Leo Cassarani
|
36
35
|
- Lonre Wang
|
37
36
|
- Luke Redpath
|
37
|
+
- Masato Nakamura
|
38
38
|
- Matt Colyer
|
39
39
|
- Mislav Marohnić
|
40
|
+
- Peter Goldstein
|
40
41
|
- Socrates Vicente
|
41
42
|
- Steffen Grunwald
|
43
|
+
- Takuya Noguchi
|
42
44
|
- Tim Barkley
|
43
45
|
autorequire:
|
44
46
|
bindir: bin
|
45
47
|
cert_chain:
|
46
48
|
- |
|
47
49
|
-----BEGIN CERTIFICATE-----
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
50
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
51
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
52
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
53
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
54
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
55
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
56
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
57
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
58
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
59
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
60
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
61
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
62
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
63
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
64
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
65
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
66
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
67
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
68
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
69
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
70
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
71
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
72
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
73
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
74
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
75
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
73
76
|
-----END CERTIFICATE-----
|
74
|
-
date:
|
75
|
-
dependencies:
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: bundler
|
78
|
-
requirement: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
type: :development
|
84
|
-
prerelease: false
|
85
|
-
version_requirements: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: rspec
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.4'
|
97
|
-
type: :development
|
98
|
-
prerelease: false
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.4'
|
77
|
+
date: 2024-05-07 00:00:00.000000000 Z
|
78
|
+
dependencies: []
|
104
79
|
description:
|
105
80
|
email:
|
106
81
|
executables: []
|
107
82
|
extensions: []
|
108
83
|
extra_rdoc_files: []
|
109
84
|
files:
|
85
|
+
- changelog.md
|
110
86
|
- lib/composite_io.rb
|
111
87
|
- lib/multipart/post.rb
|
112
88
|
- lib/multipart/post/composite_read_io.rb
|
@@ -118,10 +94,14 @@ files:
|
|
118
94
|
- lib/multipartable.rb
|
119
95
|
- lib/net/http/post/multipart.rb
|
120
96
|
- lib/parts.rb
|
97
|
+
- license.md
|
98
|
+
- readme.md
|
121
99
|
homepage: https://github.com/socketry/multipart-post
|
122
100
|
licenses:
|
123
101
|
- MIT
|
124
|
-
metadata:
|
102
|
+
metadata:
|
103
|
+
documentation_uri: https://socketry.github.io/multipart-post/
|
104
|
+
source_code_uri: https://github.com/socketry/multipart-post.git
|
125
105
|
post_install_message:
|
126
106
|
rdoc_options: []
|
127
107
|
require_paths:
|
@@ -130,14 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
110
|
requirements:
|
131
111
|
- - ">="
|
132
112
|
- !ruby/object:Gem::Version
|
133
|
-
version: 2.
|
113
|
+
version: 2.5.0
|
134
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
115
|
requirements:
|
136
116
|
- - ">="
|
137
117
|
- !ruby/object:Gem::Version
|
138
118
|
version: '0'
|
139
119
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.5.3
|
141
121
|
signing_key:
|
142
122
|
specification_version: 4
|
143
123
|
summary: A multipart form post accessory for Net::HTTP.
|
metadata.gz.sig
CHANGED
Binary file
|