25 require_once
'HTTP/Request2/Exception.php';
114 } elseif (
false === ($this->target = @fopen(
$target,
'ab'))) {
129 public function update(SplSubject $subject)
131 $event = $subject->getLastEvent();
132 if (!in_array($event[
'name'], $this->events)) {
136 switch ($event[
'name']) {
138 $this->
log(
'* Connected to ' . $event[
'data']);
141 $headers = explode(
"\r\n", $event[
'data']);
143 foreach ($headers as $header) {
144 $this->
log(
'> ' . $header);
148 $this->
log(
'> ' . $event[
'data'] .
' byte(s) sent');
150 case 'receivedHeaders':
152 '< HTTP/%s %s %s', $event[
'data']->getVersion(),
153 $event[
'data']->getStatus(), $event[
'data']->getReasonPhrase()
155 $headers = $event[
'data']->getHeader();
156 foreach ($headers as $key => $val) {
157 $this->
log(
'< ' . $key .
': ' . $val);
162 $this->
log($event[
'data']->getBody());
165 $this->
log(
'* Disconnected');
180 protected function log($message)
182 if ($this->target instanceof Log) {
183 $this->target->debug($message);
184 } elseif (is_resource($this->target)) {
185 fwrite($this->target, $message .
"\r\n");
update(SplSubject $subject)
__construct($target= 'php://output', array $events=array())