File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -566,7 +566,8 @@ class << self
566
566
#
567
567
# @return [Array(String, Enumerable<String>)]
568
568
private def encode_multipart_streaming ( body )
569
- boundary = SecureRandom . urlsafe_base64 ( 60 )
569
+ # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
570
+ boundary = SecureRandom . urlsafe_base64 ( 46 )
570
571
571
572
closing = [ ]
572
573
strio = writable_enum do |y |
Original file line number Diff line number Diff line change @@ -213,6 +213,18 @@ def env_table
213
213
end
214
214
end
215
215
216
+ def test_encoding_length
217
+ headers , = OpenAI ::Internal ::Util . encode_content (
218
+ { "content-type" => "multipart/form-data" } ,
219
+ Pathname ( __FILE__ )
220
+ )
221
+ assert_pattern do
222
+ headers . fetch ( "content-type" ) => /boundary=(.+)$/
223
+ end
224
+ field , = Regexp . last_match . captures
225
+ assert ( field . length < 70 - 6 )
226
+ end
227
+
216
228
def test_file_encode
217
229
file = Pathname ( __FILE__ )
218
230
headers = { "content-type" => "multipart/form-data" }
You can’t perform that action at this time.
0 commit comments