@@ -497,7 +497,7 @@ class << self
497497 # @param closing [Array<Proc>]
498498 # @param content_type [String, nil]
499499 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 "
501501
502502 case val
503503 in BrandDev ::FilePart
@@ -508,24 +508,21 @@ class << self
508508 content_type : val . content_type
509509 )
510510 in Pathname
511- y << "Content-Type: #{ content_type } \r \n \r \n "
511+ y << format ( content_line , content_type || "application/octet-stream" )
512512 io = val . open ( binmode : true )
513513 closing << io . method ( :close )
514514 IO . copy_stream ( io , y )
515515 in IO
516- y << "Content-Type: #{ content_type } \r \n \r \n "
516+ y << format ( content_line , content_type || "application/octet-stream" )
517517 IO . copy_stream ( val , y )
518518 in StringIO
519- y << "Content-Type: #{ content_type } \r \n \r \n "
519+ y << format ( content_line , content_type || "application/octet-stream" )
520520 y << val . string
521- in String
522- y << "Content-Type: #{ content_type } \r \n \r \n "
523- y << val . to_s
524521 in -> { primitive? ( _1 ) }
525- y << "Content-Type: text/plain\r \n \r \n "
522+ y << format ( content_line , content_type || " text/plain" )
526523 y << val . to_s
527524 else
528- y << "Content-Type: application/json\r \n \r \n "
525+ y << format ( content_line , content_type || " application/json" )
529526 y << JSON . generate ( val )
530527 end
531528 y << "\r \n "
@@ -563,6 +560,8 @@ class << self
563560
564561 # @api private
565562 #
563+ # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
564+ #
566565 # @param body [Object]
567566 #
568567 # @return [Array(String, Enumerable<String>)]
0 commit comments