@@ -41,27 +41,6 @@ class Application
4141 */
4242 protected $ kernel ;
4343
44- /**
45- * Service providers to be reset.
46- *
47- * @var array
48- */
49- protected $ providers = [];
50-
51- /**
52- * Instance names to be reset.
53- *
54- * @var array
55- */
56- protected $ instances = [];
57-
58- /**
59- * Resolved facades to be reset.
60- *
61- * @var array
62- */
63- protected $ facades = [];
64-
6544 /**
6645 * Aliases for pre-resolving.
6746 *
@@ -95,11 +74,7 @@ public function __construct($framework, $basePath = null)
9574 {
9675 $ this ->setFramework ($ framework );
9776 $ this ->setBasePath ($ basePath );
98-
9977 $ this ->bootstrap ();
100- $ this ->initProviders ();
101- $ this ->initFacades ();
102- $ this ->initInstances ();
10378 }
10479
10580 /**
@@ -119,84 +94,6 @@ protected function bootstrap()
11994 $ this ->preResolveInstances ($ application );
12095 }
12196
122- /**
123- * Initialize customized service providers.
124- */
125- protected function initProviders ()
126- {
127- $ app = $ this ->getApplication ();
128- $ providers = $ app ['config ' ]->get ('swoole_http.providers ' , []);
129-
130- foreach ($ providers as $ provider ) {
131- if (! $ provider instanceof ServiceProvider) {
132- $ provider = new $ provider ($ app );
133- }
134- $ this ->providers [get_class ($ provider )] = $ provider ;
135- }
136- }
137-
138- /**
139- * Initialize customized instances.
140- */
141- protected function initInstances ()
142- {
143- $ app = $ this ->getApplication ();
144- $ instances = $ app ['config ' ]->get ('swoole_http.instances ' , []);
145-
146- $ this ->instances = array_filter ($ instances , function ($ value ) {
147- return is_string ($ value );
148- });
149- }
150-
151- /**
152- * Initialize customized facades.
153- */
154- protected function initFacades ()
155- {
156- $ app = $ this ->getApplication ();
157- $ facades = $ app ['config ' ]->get ('swoole_http.facades ' , []);
158-
159- $ this ->facades = array_filter ($ facades , function ($ value ) {
160- return is_string ($ value );
161- });
162- }
163-
164- /**
165- * Re-register and reboot service providers.
166- */
167- public function resetProviders ()
168- {
169- foreach ($ this ->providers as $ provider ) {
170- if (method_exists ($ provider , 'register ' )) {
171- $ provider ->register ();
172- }
173-
174- if (method_exists ($ provider , 'boot ' )) {
175- $ this ->getApplication ()->call ([$ provider , 'boot ' ]);
176- }
177- }
178- }
179-
180- /**
181- * Clear resolved facades.
182- */
183- public function clearFacades ()
184- {
185- foreach ($ this ->facades as $ facade ) {
186- Facade::clearResolvedInstance ($ facade );
187- }
188- }
189-
190- /**
191- * Clear resolved instances.
192- */
193- public function clearInstances ()
194- {
195- foreach ($ this ->instances as $ instance ) {
196- $ this ->getApplication ()->forgetInstance ($ instance );
197- }
198- }
199-
20097 /**
20198 * Load application.
20299 *
@@ -260,9 +157,11 @@ public function run(Request $request)
260157 // prepare content for ob
261158 $ content = '' ;
262159 if ($ shouldUseOb ) {
263- if ($ response instanceof StreamedResponse ||
264- $ response instanceof BinaryFileResponse) {
160+ if ($ response instanceof BinaryFileResponse) {
265161 $ shouldUseOb = false ;
162+ ob_end_clean ();
163+ } elseif ($ isStream = $ response instanceof StreamedResponse) {
164+ $ response ->sendContent ();
266165 } elseif ($ response instanceof SymfonyResponse) {
267166 $ content = $ response ->getContent ();
268167 } else {
@@ -275,7 +174,11 @@ public function run(Request $request)
275174
276175 // set ob content to response
277176 if ($ shouldUseOb && strlen ($ content ) === 0 && ob_get_length () > 0 ) {
278- $ response ->setContent (ob_get_contents ());
177+ if ($ isStream ) {
178+ $ response ->output = ob_get_contents ();
179+ } else {
180+ $ response ->setContent (ob_get_contents ());
181+ }
279182 }
280183
281184 if ($ shouldUseOb ) {
@@ -375,20 +278,6 @@ public function terminate(Request $request, $response)
375278 protected function terminateLaravel (Request $ request , $ response )
376279 {
377280 $ this ->getKernel ()->terminate ($ request , $ response );
378-
379- // clean laravel session
380- if ($ request ->hasSession ()) {
381- $ session = $ request ->getSession ();
382- $ session ->flush ();
383- }
384-
385- // clean laravel cookie queue
386- if (isset ($ this ->application ['cookie ' ])) {
387- $ cookies = $ this ->application ['cookie ' ];
388- foreach ($ cookies ->getQueuedCookies () as $ name => $ cookie ) {
389- $ cookies ->unqueue ($ name );
390- }
391- }
392281 }
393282
394283 /**
0 commit comments