Skip to content

Commit

Permalink
Add chunk decoding (hard-coded for now, should be header-dependent)
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD authored and EvanDotPro committed Nov 1, 2013
1 parent e98d250 commit 0329044
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Sslurp/MozillaCertData.php
Expand Up @@ -123,7 +123,23 @@ protected function fetchLatestCertData($until = false)
'file an issue at https://github.com/EvanDotPro/Sslurp/issues');
}

return $this->getResponseBody($response);
return $this->decodeChunkedString($this->getResponseBody($response));
}

protected function decodeChunkedString($string)
{
$result = '';
$currentPos = 0;
$stringLength = strlen($string);

while ($currentPos < $stringLength) {
$position = strpos($string, "\r\n", $currentPos);
$length = hexdec(substr($string, $currentPos, $position - $currentPos));
$result .= substr($string, $position + 2, $length);
$currentPos = $position + 2;
}

return $result;
}

protected function getResponseBody($string)
Expand Down

0 comments on commit 0329044

Please sign in to comment.