This repository was archived by the owner on Mar 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 10
10
11
11
class Response
12
12
{
13
+ const CHUNK_SIZE = 1024 ;
14
+
13
15
/**
14
16
* @var \Swoole\Http\Response
15
17
*/
@@ -46,7 +48,7 @@ public function __construct($illuminateResponse, SwooleResponse $swooleResponse)
46
48
}
47
49
48
50
/**
49
- * Sends HTTP headers and content.
51
+ * Send HTTP headers and content.
50
52
*
51
53
* @throws \InvalidArgumentException
52
54
*/
@@ -57,7 +59,7 @@ public function send()
57
59
}
58
60
59
61
/**
60
- * Sends HTTP headers.
62
+ * Send HTTP headers.
61
63
*
62
64
* @throws \InvalidArgumentException
63
65
*/
@@ -103,7 +105,7 @@ protected function sendHeaders()
103
105
}
104
106
105
107
/**
106
- * Sends HTTP content.
108
+ * Send HTTP content.
107
109
*/
108
110
protected function sendContent ()
109
111
{
@@ -126,10 +128,13 @@ protected function sendContent()
126
128
*/
127
129
protected function sendInChunk ($ content )
128
130
{
129
- if ($ content ) {
130
- foreach (str_split ($ content , 1024 ) as $ v ) {
131
- $ this ->swooleResponse ->write ($ v );
132
- }
131
+ if (strlen ($ content ) <= static ::CHUNK_SIZE ) {
132
+ $ this ->swooleResponse ->end ($ content );
133
+ return ;
134
+ }
135
+
136
+ foreach (str_split ($ content , static ::CHUNK_SIZE ) as $ chunk ) {
137
+ $ this ->swooleResponse ->write ($ chunk );
133
138
}
134
139
135
140
$ this ->swooleResponse ->end ();
You can’t perform that action at this time.
0 commit comments