Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into no
Browse files Browse the repository at this point in the history
  • Loading branch information
roheim committed Feb 23, 2012
2 parents 721f88b + d2f65cb commit c88dfd5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
21 changes: 15 additions & 6 deletions src/Header/SetCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,30 @@ public function getFieldValue()
throw new Exception\RuntimeException('A cookie name is required to generate a field value for this cookie');
}
$fieldValue = $this->getName() . '=' . urlencode($this->getValue());
if (($expires = $this->getExpires())) {

$expires = $this->getExpires();
if ($expires) {
$fieldValue .= '; Expires=' . $expires;
}
if (($domain = $this->getDomain())) {

$domain = $this->getDomain();
if ($domain) {
$fieldValue .= '; Domain=' . $domain;
}
if (($path = $this->getPath())) {

$path = $this->getPath();
if ($path) {
$fieldValue .= '; Path=' . $path;
}

if ($this->isSecure()) {
$fieldValue .= '; Secure';
}

if ($this->isHttponly()) {
$fieldValue .= '; HttpOnly';
}

return $fieldValue;
}

Expand Down Expand Up @@ -362,15 +371,15 @@ public function isValidForRequest($requestDomain, $path, $isSecure = false)
if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) !== false)) {
return false;
}

if ($this->getPath() && (strpos($path, $this->getPath()) !== 0)) {
return false;
}

if ($this->secure && $this->isSecure()!==$isSecure) {
return false;
}

return true;

}
Expand Down
10 changes: 3 additions & 7 deletions src/Response/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ public function setStreamName($stream_name) {
public static function fromStream($response_str, $stream)
{
$response= new static();

$response::fromString($response_str);
if (is_resource($stream)) {
$response->setStream($stream);
}

return $response;
}

Expand Down Expand Up @@ -190,11 +190,7 @@ protected function readStream()
return '';
}

if(isset($headers['content-length'])) {
$this->body = stream_get_contents($this->stream, $headers['content-length']);
} else {
$this->body = stream_get_contents($this->stream);
}
$this->body = stream_get_contents($this->stream);
fclose($this->stream);
$this->stream = null;
}
Expand Down

0 comments on commit c88dfd5

Please sign in to comment.