comparison vendor/zendframework/zend-diactoros/src/Server.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children c2387f117808
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
1 <?php 1 <?php
2 /** 2 /**
3 * Zend Framework (http://framework.zend.com/) 3 * @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4 * 4 * @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5 * @see http://github.com/zendframework/zend-diactoros for the canonical source repository
6 * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License 5 * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
8 */ 6 */
9 7
10 namespace Zend\Diactoros; 8 namespace Zend\Diactoros;
11 9
148 * "Listen" to an incoming request 146 * "Listen" to an incoming request
149 * 147 *
150 * If provided a $finalHandler, that callable will be used for 148 * If provided a $finalHandler, that callable will be used for
151 * incomplete requests. 149 * incomplete requests.
152 * 150 *
153 * Output buffering is enabled prior to invoking the attached
154 * callback; any output buffered will be sent prior to any
155 * response body content.
156 *
157 * @param null|callable $finalHandler 151 * @param null|callable $finalHandler
158 */ 152 */
159 public function listen(callable $finalHandler = null) 153 public function listen(callable $finalHandler = null)
160 { 154 {
161 $callback = $this->callback; 155 $callback = $this->callback;
162 156
163 ob_start();
164 $bufferLevel = ob_get_level();
165
166 $response = $callback($this->request, $this->response, $finalHandler); 157 $response = $callback($this->request, $this->response, $finalHandler);
167 if (! $response instanceof ResponseInterface) { 158 if (! $response instanceof ResponseInterface) {
168 $response = $this->response; 159 $response = $this->response;
169 } 160 }
170 $this->getEmitter()->emit($response, $bufferLevel); 161
162 $this->getEmitter()->emit($response);
171 } 163 }
172 164
173 /** 165 /**
174 * Retrieve the current response emitter. 166 * Retrieve the current response emitter.
175 * 167 *