@@ -497,7 +497,7 @@ class << self
497
497
# @param closing [Array<Proc>]
498
498
# @param content_type [String, nil]
499
499
private def write_multipart_content ( y , val :, closing :, content_type : nil )
500
- content_type || = "application/octet-stream "
500
+ content_line = "Content-Type: %s \r \n \r \n "
501
501
502
502
case val
503
503
in OnebusawaySDK ::FilePart
@@ -508,24 +508,21 @@ class << self
508
508
content_type : val . content_type
509
509
)
510
510
in Pathname
511
- y << "Content-Type: #{ content_type } \r \n \r \n "
511
+ y << format ( content_line , content_type || "application/octet-stream" )
512
512
io = val . open ( binmode : true )
513
513
closing << io . method ( :close )
514
514
IO . copy_stream ( io , y )
515
515
in IO
516
- y << "Content-Type: #{ content_type } \r \n \r \n "
516
+ y << format ( content_line , content_type || "application/octet-stream" )
517
517
IO . copy_stream ( val , y )
518
518
in StringIO
519
- y << "Content-Type: #{ content_type } \r \n \r \n "
519
+ y << format ( content_line , content_type || "application/octet-stream" )
520
520
y << val . string
521
- in String
522
- y << "Content-Type: #{ content_type } \r \n \r \n "
523
- y << val . to_s
524
521
in -> { primitive? ( _1 ) }
525
- y << "Content-Type: text/plain\r \n \r \n "
522
+ y << format ( content_line , content_type || " text/plain" )
526
523
y << val . to_s
527
524
else
528
- y << "Content-Type: application/json\r \n \r \n "
525
+ y << format ( content_line , content_type || " application/json" )
529
526
y << JSON . generate ( val )
530
527
end
531
528
y << "\r \n "
@@ -563,6 +560,8 @@ class << self
563
560
564
561
# @api private
565
562
#
563
+ # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
564
+ #
566
565
# @param body [Object]
567
566
#
568
567
# @return [Array(String, Enumerable<String>)]
0 commit comments