Browse Source

Merge pull request #13690 from littleylv/master

Remove unnecessary quotes and \r\n in FormData format
Mark Story 6 years ago
parent
commit
448f30918f
2 changed files with 3 additions and 6 deletions
  1. 2 2
      src/Http/Client/FormData.php
  2. 1 4
      tests/TestCase/Http/Client/FormDataTest.php

+ 2 - 2
src/Http/Client/FormData.php

@@ -230,7 +230,7 @@ class FormData implements Countable
             return 'application/x-www-form-urlencoded';
             return 'application/x-www-form-urlencoded';
         }
         }
 
 
-        return 'multipart/form-data; boundary="' . $this->boundary() . '"';
+        return 'multipart/form-data; boundary=' . $this->boundary();
     }
     }
 
 
     /**
     /**
@@ -249,7 +249,7 @@ class FormData implements Countable
                 $out .= (string)$part;
                 $out .= (string)$part;
                 $out .= "\r\n";
                 $out .= "\r\n";
             }
             }
-            $out .= "--$boundary--\r\n\r\n";
+            $out .= "--$boundary--\r\n";
 
 
             return $out;
             return $out;
         }
         }

+ 1 - 4
tests/TestCase/Http/Client/FormDataTest.php

@@ -116,7 +116,6 @@ class FormDataTest extends TestCase
             'value',
             'value',
             '--' . $boundary . '--',
             '--' . $boundary . '--',
             '',
             '',
-            '',
         ];
         ];
         $this->assertEquals(implode("\r\n", $expected), (string)$data);
         $this->assertEquals(implode("\r\n", $expected), (string)$data);
     }
     }
@@ -163,7 +162,6 @@ class FormDataTest extends TestCase
             $contents,
             $contents,
             '--' . $boundary . '--',
             '--' . $boundary . '--',
             '',
             '',
-            ''
         ];
         ];
         $this->assertEquals(implode("\r\n", $expected), $result);
         $this->assertEquals(implode("\r\n", $expected), $result);
     }
     }
@@ -194,7 +192,6 @@ class FormDataTest extends TestCase
             $contents,
             $contents,
             '--' . $boundary . '--',
             '--' . $boundary . '--',
             '',
             '',
-            ''
         ];
         ];
         $this->assertEquals(implode("\r\n", $expected), $result);
         $this->assertEquals(implode("\r\n", $expected), $result);
     }
     }
@@ -217,7 +214,7 @@ class FormDataTest extends TestCase
         $data->addFile('upload', fopen($file, 'r'));
         $data->addFile('upload', fopen($file, 'r'));
         $boundary = $data->boundary();
         $boundary = $data->boundary();
         $result = $data->contentType();
         $result = $data->contentType();
-        $expected = 'multipart/form-data; boundary="' . $boundary . '"';
+        $expected = 'multipart/form-data; boundary=' . $boundary;
         $this->assertEquals($expected, $result);
         $this->assertEquals($expected, $result);
     }
     }
 }
 }