private function header_callback($ch, $headers)
{
$parts = explode(":", $headers, 2);
// extract status code
if (preg_match('/HTTP\\/1.\\d+ (\\d+)/', $headers, $matches)) {
$this->response->setStatusCode($matches[1]);
} else {
if (count($parts) == 2) {
$name = strtolower($parts[0]);
$value = trim($parts[1]);
// this must be a header: value line
$this->response->headers->set($name, $value, false);
} else {
// this is hacky but until anyone comes up with a better way...
$event = new ProxyEvent(array('request' => $this->request, 'response' => $this->response, 'proxy' => &$this));
// this is the end of headers - last line is always empty - notify the dispatcher about this
$this->dispatcher->dispatch('request.sent', $event);
}
}
return strlen($headers);
}