当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpRequest::getRawResponseMessage方法代码示例

本文整理汇总了PHP中HttpRequest::getRawResponseMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpRequest::getRawResponseMessage方法的具体用法?PHP HttpRequest::getRawResponseMessage怎么用?PHP HttpRequest::getRawResponseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpRequest的用法示例。


在下文中一共展示了HttpRequest::getRawResponseMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRemoveUsersCapabilities

 public function testRemoveUsersCapabilities()
 {
     $a = array('RequestMethod' => 'RemoveUserCapabilities', 'OwnerID' => 'efb00dbb-d4ab-46dc-aebc-4ba83288c3c0');
     $r = new HttpRequest($this->server_url, HttpRequest::METH_POST);
     $r->addPostFields($a);
     $r->send();
     echo $r->getRawRequestMessage();
     echo "\n";
     echo $r->getRawResponseMessage();
     echo "\n";
     $this->assertEquals(200, $r->getResponseCode());
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:12,代码来源:UserServiceTests.php

示例2: request

 public function request($method, stdClass $params = null, $namespace = null)
 {
     if (!$namespace) {
         $namespace = $this->namespace;
     }
     $requestObj = new stdClass();
     $requestObj->id = microtime(true);
     $requestObj->method = $method;
     $requestObj->params = new stdClass();
     $this->walkSerialize($params, $requestObj->params, 'underScope');
     $jsonRequest = $this->cryptoTool->encrypt(json_encode($requestObj), $this->dbServer->GetKey(true));
     $dt = new DateTime('now', new DateTimeZone("UTC"));
     $timestamp = $dt->format("D d M Y H:i:s e");
     $canonical_string = $jsonRequest . $timestamp;
     $signature = base64_encode(hash_hmac('SHA1', $canonical_string, $this->dbServer->GetKey(true), 1));
     $request = new HttpRequest();
     $request->setMethod(HTTP_METH_POST);
     // If no VPC router communicating via local inteface (Scalr should be setup within the esame network)
     $requestHost = $this->dbServer->getSzrHost() . ":{$this->port}";
     if ($this->isVPC) {
         $routerFarmRoleId = $this->dbServer->GetFarmRoleObject()->GetSetting(Scalr_Role_Behavior_Router::ROLE_VPC_SCALR_ROUTER_ID);
         if ($routerFarmRoleId) {
             $routerRole = DBFarmRole::LoadByID($routerFarmRoleId);
         } else {
             $routerRole = $this->dbServer->GetFarmObject()->GetFarmRoleByBehavior(ROLE_BEHAVIORS::VPC_ROUTER);
         }
         if ($routerRole) {
             // No public IP need to use proxy
             if (!$this->dbServer->remoteIp) {
                 $requestHost = $routerRole->GetSetting(Scalr_Role_Behavior_Router::ROLE_VPC_IP) . ":80";
                 $request->addHeaders(array("X-Receiver-Host" => $this->dbServer->localIp, "X-Receiver-Port" => $this->port));
                 // There is public IP, can use it
             } else {
                 $requestHost = "{$this->dbServer->remoteIp}:{$this->port}";
             }
         }
     }
     $request->setUrl("http://{$requestHost}/{$namespace}");
     $request->setOptions(array('timeout' => $this->timeout, 'connecttimeout' => 10));
     $request->addHeaders(array("Date" => $timestamp, "X-Signature" => $signature, "X-Server-Id" => $this->dbServer->serverId));
     $request->setBody($jsonRequest);
     try {
         // Send request
         $request->send();
         $this->debug['responseCode'] = $request->getResponseCode();
         $this->debug['fullResponse'] = $request->getRawResponseMessage();
         if ($request->getResponseCode() == 200) {
             $response = $request->getResponseData();
             $body = $this->cryptoTool->decrypt($response['body'], $this->dbServer->GetKey(true));
             $jResponse = @json_decode($body);
             if ($jResponse->error) {
                 throw new Exception("{$jResponse->error->message} ({$jResponse->error->code}): {$jResponse->error->data}");
             }
             return $jResponse;
         } else {
             $response = $request->getResponseData();
             throw new Exception(sprintf("Unable to perform request to scalarizr: %s (%s)", $response['body'], $request->getResponseCode()));
         }
     } catch (HttpException $e) {
         if (isset($e->innerException)) {
             $msg = $e->innerException->getMessage();
         } else {
             $msg = $e->getMessage();
         }
         if (stristr($msg, "Namespace not found")) {
             $msg = "Feature not supported by installed version of scalarizr. Please update it to the latest version and try again.";
         }
         throw new Exception(sprintf("Unable to perform request to scalarizr: %s", $msg));
     }
 }
开发者ID:rickb838,项目名称:scalr,代码行数:70,代码来源:Client.php

示例3: header

    exit;
}
// Header handling
foreach (array('Content-Type') as $name) {
    $content = $response->getHeader($name);
    if ($content) {
        header("{$name}: {$content}");
    }
}
$debug = 0;
// debugging
if ($debug) {
    echo "DEBUGGING CALL TO <a href='{$url}'>{$url}</a>:\n<br>";
    echo 'Seen by pecl extension as:' . $request->getUrl();
    echo '<h2>Request</h2> <pre>' . $request->getRawRequestMessage() . '</pre>';
    echo '<h2>Response</h2> <pre>' . $request->getRawResponseMessage() . '</pre>';
    echo '<h2>Output headers</h2> <pre>';
    print_r(headers_list());
    print '</pre>';
    echo '<h2>Content</h2>';
    echo $response->getBody();
    exit;
}
// well, that's our body
$contents = $response->getBody();
// Take a short look if we got HTML (important for rewrite engine)
$is_html = stripos($response->getHeader('Content-Type'), 'html') !== false;
// rewrite the page...
$db->driver->rewrite_page($url, $contents, $is_html);
// and print it out.
echo $contents;
开发者ID:BackupTheBerlios,项目名称:biokemika-svn,代码行数:31,代码来源:proxy.php


注:本文中的HttpRequest::getRawResponseMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。