/** * @covers WindowsAzure\Common\Internal\Http\HttpClient::getBody */ public function testGetBody() { // Setup $channel = new HttpClient(); $expected = 'new body'; $channel->setBody($expected); // Test $actual = $channel->getBody(); // Assert $this->assertEquals($expected, $actual); }
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); }
/** * Upload asset file to storage. * * @param WindowsAzure\MediaServices\Models\Locator $locator Write locator for * file upload * * @param string $name Uploading filename * @param string $body Uploading content * * @return none */ public function uploadAssetFile($locator, $name, $body) { Validate::isA($locator, 'WindowsAzure\\Mediaservices\\Models\\Locator', 'locator'); Validate::isString($name, 'name'); Validate::notNull($body, 'body'); $method = Resources::HTTP_PUT; $urlFile = $locator->getBaseUri() . '/' . $name; $url = new Url($urlFile . $locator->getContentAccessComponent()); $filters = array(); $statusCode = Resources::STATUS_CREATED; $headers = array(Resources::CONTENT_TYPE => Resources::BINARY_FILE_TYPE, Resources::X_MS_VERSION => Resources::STORAGE_API_LATEST_VERSION, Resources::X_MS_BLOB_TYPE => BlobType::BLOCK_BLOB); $httpClient = new HttpClient(); $httpClient->setMethod($method); $httpClient->setHeaders($headers); $httpClient->setExpectedStatusCode($statusCode); $httpClient->setBody($body); $httpClient->send($filters, $url); }