Merge pull request #433 from juneszh/master

add content_length configuration
pull/434/head
Mike Cao 4 years ago committed by GitHub
commit b6429d2a3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -141,6 +141,7 @@ class Engine {
$this->set('flight.log_errors', false);
$this->set('flight.views.path', './views');
$this->set('flight.views.extension', '.php');
$this->set('flight.content_length', true);
// Startup configuration
$this->before('start', function() use ($self) {
@ -152,6 +153,8 @@ class Engine {
// Set case-sensitivity
$self->router()->case_sensitive = $self->get('flight.case_sensitive');
// Set Content-Length
$self->response()->content_length = $self->get('flight.content_length');
});
$initialized = true;

@ -34,6 +34,13 @@ class Response {
*/
protected $sent = false;
/**
* header Content-Length
*
* @var boolean
*/
public $content_length = true;
/**
* @var array HTTP status codes
*/
@ -251,12 +258,14 @@ class Response {
}
}
if ($this->content_length) {
// Send content length
$length = $this->getContentLength();
if ($length > 0) {
header('Content-Length: '.$length);
}
}
return $this;
}

Loading…
Cancel
Save