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

Commit

Permalink
Merge branch 'features/http_auth-http_api'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Oct 4, 2011
5 parents 2549b87 + 47be447 + b60e5b4 + 01c627a + 16ff2fe commit c7d790d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/Header/ProxyAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @throws Exception\InvalidArgumentException
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.33
*/
class ProxyAuthenticate implements HeaderDescription
class ProxyAuthenticate implements MultipleHeaderDescription
{

public static function fromString($headerLine)
Expand Down Expand Up @@ -41,4 +41,17 @@ public function toString()
return 'Proxy-Authenticate: ' . $this->getFieldValue();
}

public function toStringMultipleHeaders(array $headers)
{
$strings = array($this->toString());
foreach ($headers as $header) {
if (!$header instanceof ProxyAuthenticate) {
throw new Exception\RuntimeException(
'The ProxyAuthenticate multiple header implementation can only accept an array of ProxyAuthenticate headers'
);
}
$strings[] = $header->toString();
}
return implode("\r\n", $strings);
}
}
15 changes: 14 additions & 1 deletion src/Header/WWWAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @throws Exception\InvalidArgumentException
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47
*/
class WWWAuthenticate implements HeaderDescription
class WWWAuthenticate implements MultipleHeaderDescription
{

public static function fromString($headerLine)
Expand Down Expand Up @@ -41,4 +41,17 @@ public function toString()
return 'WWW-Authenticate: ' . $this->getFieldValue();
}

public function toStringMultipleHeaders(array $headers)
{
$strings = array($this->toString());
foreach ($headers as $header) {
if (!$header instanceof WWWAuthenticate) {
throw new Exception\RuntimeException(
'The WWWAuthenticate multiple header implementation can only accept an array of WWWAuthenticate headers'
);
}
$strings[] = $header->toString();
}
return implode("\r\n", $strings);
}
}

0 comments on commit c7d790d

Please sign in to comment.