File tree Expand file tree Collapse file tree 1 file changed +24
-18
lines changed
Expand file tree Collapse file tree 1 file changed +24
-18
lines changed Original file line number Diff line number Diff line change 1212
1313namespace think ;
1414
15+ use Throwable ;
16+
1517/**
1618 * 响应输出基础类
1719 * @package think
@@ -127,29 +129,33 @@ public function setSession(Session $session)
127129 */
128130 public function send (): void
129131 {
130- // 处理输出数据
131- $ data = $ this ->getContent ();
132-
133- if (!headers_sent ()) {
134- if (!empty ($ this ->header )) {
135- // 发送状态码
136- http_response_code ($ this ->code );
137- // 发送头部信息
138- foreach ($ this ->header as $ name => $ val ) {
139- header ($ name . (!is_null ($ val ) ? ': ' . $ val : '' ));
132+ try {
133+ // 处理输出数据
134+ $ data = $ this ->getContent ();
135+ if (!headers_sent ()) {
136+ if (!empty ($ this ->header )) {
137+ // 发送状态码
138+ http_response_code ($ this ->code );
139+ // 发送头部信息
140+ foreach ($ this ->header as $ name => $ val ) {
141+ header ($ name . (!is_null ($ val ) ? ': ' . $ val : '' ));
142+ }
140143 }
141- }
142144
143- if ($ this ->cookie ) {
144- $ this ->cookie ->save ();
145+ if ($ this ->cookie ) {
146+ $ this ->cookie ->save ();
147+ }
145148 }
146- }
147149
148- $ this ->sendData ($ data );
150+ $ this ->sendData ($ data );
149151
150- if (function_exists ('fastcgi_finish_request ' )) {
151- // 提高页面响应
152- fastcgi_finish_request ();
152+ if (function_exists ('fastcgi_finish_request ' )) {
153+ // 提高页面响应
154+ fastcgi_finish_request ();
155+ }
156+ } catch (Throwable $ e ) {
157+ // 继续执行,不中断响应发送
158+ Container::getInstance ()->log ->error ($ e ->getMessage ());
153159 }
154160 }
155161
You can’t perform that action at this time.
0 commit comments