|
7 | 7 |
|
8 | 8 | class StatementIndexController { |
9 | 9 |
|
10 | | - const BOUNDARY = 'abcABC0123\'()+_,-./:=?'; |
11 | 10 | const EOL = "\r\n"; |
12 | 11 |
|
13 | 12 | /** |
@@ -48,7 +47,7 @@ public function index($options) { |
48 | 47 |
|
49 | 48 | // Defines the content type and body of the response. |
50 | 49 | if ($opts['attachments'] === true) { |
51 | | - $content_type = 'multipart/mixed; boundary='.static::BOUNDARY; |
| 50 | + $content_type = Helpers::mixedMultipartContentType(); |
52 | 51 | $body = function () use ($statements, $count, $opts) { |
53 | 52 | return $this->makeAttachmentsResult($statements, $count, $opts); |
54 | 53 | }; |
@@ -97,9 +96,8 @@ private function makeStatementsResult(array $statements, $count, array $opts) { |
97 | 96 | * @return \stdClass |
98 | 97 | */ |
99 | 98 | private function makeAttachmentsResult(array $statements, $count, array $opts) { |
100 | | - $boundary = static::BOUNDARY; |
| 99 | + $boundary = Helpers::MULTIPART_BOUNDARY; |
101 | 100 | $eol = static::EOL; |
102 | | - $content_type = 'multipart/mixed; boundary='.$boundary; |
103 | 101 |
|
104 | 102 | $this->emit("--$boundary$eol"); |
105 | 103 | $this->emit("Content-Type:application/json$eol$eol"); |
@@ -128,6 +126,7 @@ private function makeAttachmentsResult(array $statements, $count, array $opts) { |
128 | 126 | } |
129 | 127 |
|
130 | 128 | private function emit($value) { |
| 129 | + if (ob_get_level() == 0) ob_start(); |
131 | 130 | echo $value; |
132 | 131 | flush(); |
133 | 132 | ob_flush(); |
|
0 commit comments