Skip to content

Commit

Permalink
improvements code
Browse files Browse the repository at this point in the history
  • Loading branch information
KorsaR-ZN committed Sep 3, 2015
1 parent 5719740 commit fae48dd
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions phalcon/http/response.zep
Expand Up @@ -574,25 +574,24 @@ class Response implements ResponseInterface, InjectionAwareInterface, EventsAwar
/**
* Sends headers to the client
*/
public function sendHeaders() -> <Response>
public function sendHeaders() -> <Response> | boolean
{
var headers, eventsManager;

let headers = this->_headers;
let headers = <HeadersInterface> this->getHeaders();
let eventsManager = <ManagerInterface> this->getEventsManager();

if typeof eventsManager == "object" {
if eventsManager->fire("response:beforeSendHeaders", this) === false {
return this;
return false;
}
}

if typeof headers == "object" {
headers->send();

if eventsManager instanceof ManagerInterface {
eventsManager->fire("response:afterSendHeaders", this);
}
/**
* Send headers
*/
if headers->send() && typeof eventsManager == "object" {
eventsManager->fire("response:afterSendHeaders", this);
}

return this;
Expand Down Expand Up @@ -625,18 +624,12 @@ class Response implements ResponseInterface, InjectionAwareInterface, EventsAwar
/**
* Send headers
*/
let headers = this->_headers;
if typeof headers == "object" {
headers->send();
}
this->sendHeaders();

/**
* Send Cookies/comment>
*/
let cookies = this->_cookies;
if typeof cookies == "object" {
cookies->send();
}
this->sendCookies();

/**
* Output the response body
Expand Down

0 comments on commit fae48dd

Please sign in to comment.