本文整理汇总了PHP中unknown::getBody方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown::getBody方法的具体用法?PHP unknown::getBody怎么用?PHP unknown::getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown
的用法示例。
在下文中一共展示了unknown::getBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputResponse
/**
* Prints the response from SmartCloud or IBM Connections on Premise.
*
* @param unknown $response
*/
public function outputResponse($response, $url)
{
$store = SBTCredentialStore::getInstance();
if ($response->getStatusCode() == 200) {
if (isset($_REQUEST["isAuthenticated"]) && $settings->getAuthenticationMethod() == "basic") {
$result = array('status' => $response->getStatusCode(), 'result' => $response->getStatusCode() == 401 ? false : true);
print_r(json_encode($result));
} else {
foreach ($response->getHeaderLines() as $h) {
if (strpos($h, "Content-Type") === 0) {
header($h, TRUE);
}
}
header(':', true, $response->getStatusCode());
header('X-PHP-Response-Code: ' . $response->getStatusCode(), true, $response->getStatusCode());
if (isset($_REQUEST['actionType']) && $_REQUEST['actionType'] == 'download' || strpos($url, '/media/') != false && strpos($url, '/document/') != false) {
$headers = $response->getHeaders();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: ' . $headers['content-disposition']);
header('Content-Transfer-Encoding: binary');
//changed to chunked
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
print_r($response->getBody(TRUE));
}
} else {
if ($response->getStatusCode() == 302) {
$headers = $response->getHeaders();
$this->route($headers['location']);
} else {
if ($response->getStatusCode() == 201) {
$result = array('status' => 201, 'result' => true);
print_r(json_encode($result));
} else {
if ($response->getStatusCode() == 400) {
echo "400 - Bad Request";
print_r($response->getBody(TRUE));
} else {
if ($response->getStatusCode() == 401 || $response->getStatusCode() == '401oauth_token_expired') {
if (isset($_GET['endpointName'])) {
$store->deleteOAuthCredentials($_GET['endpointName']);
$store->deleteBasicAuthCredentials($_GET['endpointName']);
} else {
$store->deleteOAuthCredentials();
$store->deleteBasicAuthCredentials();
}
print_r($response->getStatusCode());
} else {
print_r($response->getBody(TRUE));
}
}
}
}
}
}
示例2: parseBinaryFrame
/**
* Parse binary frame.
*
* @param unknown $frame
* @return stdClass | array |
*/
public function parseBinaryFrame($frame)
{
$data = NULL;
$frameBody = NULL;
$traceId = NULL;
// check frame flags
$flagStatus = $this->_checkFrameFlags($frame->getFlag());
// do we need to decompress
// @TODO need to add check to see which compression has been used, can't assume snappy
// all the time...
if ($flagStatus->compression) {
$frameBody = snappy_uncompress($frame->getBody());
} else {
$frameBody = $frame->getBody();
}
// do we need to grab a tracing id
if ($flagStatus->tracing) {
$traceId = $this->parseUuid($frameBody);
}
switch ($frame->getOpcode()) {
case \McFrazier\PhpBinaryCql\CqlConstants::FRAME_OPCODE_ERROR:
$data = $this->parseError($frameBody);
break;
case \McFrazier\PhpBinaryCql\CqlConstants::FRAME_OPCODE_SUPPORTED:
$data = $this->parseStringMultimap($frameBody);
break;
case \McFrazier\PhpBinaryCql\CqlConstants::FRAME_OPCODE_RESULT:
$data = $this->parseResult($frameBody);
break;
case \McFrazier\PhpBinaryCql\CqlConstants::FRAME_OPCODE_AUTHENTICATE:
$data = $this->parseString($frameBody);
break;
}
// add the tracing id... if present
if ($traceId) {
$data->traceId = $traceId;
}
return $data;
}