Beispiel #1
0
 /**
  * @covers WindowsAzure\Common\Internal\Http\Url::setQueryVariables
  */
 public function testSetQueryVariables()
 {
     // Setup
     $urlString = TestResources::VALID_URL;
     $expectedQueryVariables = array(TestResources::HEADER1 => TestResources::HEADER1_VALUE, TestResources::HEADER2 => TestResources::HEADER2_VALUE);
     $url = new Url($urlString);
     // Test
     $url->setQueryVariables($expectedQueryVariables);
     // Assert
     $this->assertEquals($expectedQueryVariables, $url->getQueryVariables());
 }
 private function _commitBlocks($url, $blockIds)
 {
     $baseUrl = new Url($url);
     $baseUrl->setQueryVariable(Resources::QP_COMP, 'blocklist');
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('BlockList');
     foreach ($blockIds as $blockId) {
         $xml->writeElement('Latest', $blockId);
     }
     $xml->endElement();
     $xml->endDocument();
     $xmlContent = $xml->outputMemory();
     $method = Resources::HTTP_PUT;
     $filters = array();
     $statusCode = Resources::STATUS_CREATED;
     $headers = array(Resources::CONTENT_TYPE => Resources::BINARY_FILE_TYPE, Resources::X_MS_VERSION => Resources::STORAGE_API_LATEST_VERSION);
     $httpClient = new HttpClient();
     $httpClient->setMethod($method);
     $httpClient->setHeaders($headers);
     $httpClient->setExpectedStatusCode($statusCode);
     $httpClient->setBody($xmlContent);
     $httpClient->send($filters, $baseUrl);
 }
Beispiel #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)
 {
     $channel = clone $this->_channel;
     $contextUrl = $context->getUri();
     $url = new Url(empty($contextUrl) ? $this->_uri : $contextUrl);
     $headers = $context->getHeaders();
     $statusCodes = $context->getStatusCodes();
     $body = $context->getBody();
     $queryParams = $context->getQueryParameters();
     $postParameters = $context->getPostParameters();
     $path = $context->getPath();
     $channel->setMethod($context->getMethod());
     $channel->setExpectedStatusCode($statusCodes);
     $channel->setBody($body);
     $channel->setHeaders($headers);
     if (count($postParameters) > 0) {
         $channel->setPostParameters($postParameters);
     }
     $url->setQueryVariables($queryParams);
     $url->appendUrlPath($path);
     $channel->send($this->_filters, $url);
     return $channel->getResponse();
 }