/**
  * Sends HTTP request with the specified parameters.
  * 
  * @param string $method         HTTP method used in the request
  * @param array  $headers        HTTP headers.
  * @param array  $queryParams    URL query parameters.
  * @param array  $postParameters The HTTP POST parameters.
  * @param string $path           URL path
  * @param int    $statusCode     Expected status code received in the response
  * @param string $body           Request body
  * 
  * @return \HTTP_Request2_Response
  */
 protected function send($method, $headers, $queryParams, $postParameters, $path, $statusCode, $body = Resources::EMPTY_STRING)
 {
     $context = new HttpCallContext();
     $context->setBody($body);
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->setPostParameters($postParameters);
     if (is_array($statusCode)) {
         $context->setStatusCodes($statusCode);
     } else {
         $context->addStatusCode($statusCode);
     }
     return $this->sendContext($context);
 }
예제 #2
0
 /**
  * Gets table entity.
  * 
  * @param string                     $table        The name of the table.
  * @param string                     $partitionKey The entity partition key.
  * @param string                     $rowKey       The entity row key.
  * @param Models\TableServiceOptions $options      The optional parameters.
  * 
  * @return Models\GetEntityResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx
  */
 public function getEntity($table, $partitionKey, $rowKey, $options = null)
 {
     Validate::isString($table, 'table');
     Validate::notNullOrEmpty($table, 'table');
     Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG);
     Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG);
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_OK;
     $path = $this->_getEntityPath($table, $partitionKey, $rowKey);
     if (is_null($options)) {
         $options = new TableServiceOptions();
     }
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $context = new HttpCallContext();
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->addStatusCode($statusCode);
     $response = $this->sendContext($context);
     $entity = $this->_atomSerializer->parseEntity($response->getBody());
     $result = new GetEntityResult();
     $result->setEntity($entity);
     return $result;
 }