コード例 #1
0
 /**
  * @covers WindowsAzure\Common\Internal\Http\BatchRequest::getHeaders
  */
 public function testGetHeaders()
 {
     //  Setup
     $batchReq = new BatchRequest();
     $context = new HttpCallContext();
     $body = 'test body';
     $uri = 'http://www.someurl.com';
     $context->setBody($body);
     $context->setUri($uri);
     // Test
     $batchReq->appendContext($context);
     $batchReq->encode();
     $resultHeader = $batchReq->getHeaders();
     // Assert
     $this->assertEquals(1, count($resultHeader));
     $this->assertContains('multipart/mixed', $resultHeader['Content-Type']);
 }
コード例 #2
0
 /**
  * Create task template HTTP call context
  *
  * @param WindowsAzure\MediaServices\Models\TaskTemplate $taskTemplate Task
  * template object to be created
  *
  * @return WindowsAzure\Common\Internal\Http\HttpCallContext
  */
 private function _getCreateTaskTemplateContext($taskTemplate)
 {
     Validate::isA($taskTemplate, 'WindowsAzure\\MediaServices\\Models\\TaskTemplate', 'taskTemplate');
     $result = new HttpCallContext();
     $result->setMethod(Resources::HTTP_POST);
     $result->setHeaders($this->_batchHeaders);
     $result->setUri($this->getUri());
     $result->setPath('/$1/TaskTemplates');
     $result->setBody($this->wrapAtomEntry($taskTemplate));
     $result->addStatusCode(Resources::STATUS_CREATED);
     return $result;
 }
コード例 #3
0
 /**
  * Sends HTTP request with the specified HTTP call context.
  * 
  * @param WindowsAzure\Common\Internal\Http\HttpCallContext $context The HTTP 
  * call context.
  * 
  * @return \HTTP_Request2_Response
  */
 protected function sendContext($context)
 {
     $context->setUri($this->getUri());
     return parent::sendContext($context);
 }
コード例 #4
0
 /**
  * Constructs HTTP call context for insertEntity API.
  * 
  * @param string                     $table   The name of the table.
  * @param Models\Entity              $entity  The table entity.
  * @param Models\TableServiceOptions $options The optional parameters.
  * 
  * @return HttpCallContext
  */
 private function _constructInsertEntityContext($table, $entity, $options)
 {
     Validate::isString($table, 'table');
     Validate::notNullOrEmpty($table, 'table');
     Validate::notNullOrEmpty($entity, 'entity');
     Validate::isTrue($entity->isValid($msg), $msg);
     $method = Resources::HTTP_POST;
     $context = new HttpCallContext();
     $headers = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_CREATED;
     $path = $table;
     $body = $this->_atomSerializer->getEntity($entity);
     if (is_null($options)) {
         $options = new TableServiceOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $context->setBody($body);
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->addStatusCode($statusCode);
     $context->setUri($this->getUri());
     return $context;
 }