public function sendRequest(HttpRequest $request, ExecutionContext $context)
 {
     $request->addHeader(HttpHeaders::USER_AGENT, $this->userAgent);
     $context->getSigner()->sign($request, $context->getCredentials());
     $response = $this->client->sendRequest($request, $context);
     foreach ($context->getResponseHandlers() as $handler) {
         $handler->handle($response);
     }
     return $response;
 }
Exemple #2
0
 protected function getContext($options)
 {
     $context = new ExecutionContext();
     $context->setCredentials(array(OSSOptions::ACCESS_KEY_ID => $options[OSSOptions::ACCESS_KEY_ID], OSSOptions::ACCESS_KEY_SECRET => $options[OSSOptions::ACCESS_KEY_SECRET]));
     $context->setResponseHandler($this->getResponseHandlers($options));
     $bucket = isset($options[OSSOptions::BUCKET]) ? $options[OSSOptions::BUCKET] : null;
     $key = isset($options[OSSOptions::KEY]) ? $options[OSSOptions::KEY] : null;
     $context->setSigner(new OSSRequestSigner($bucket, $key));
     $context->setParameter('Command', $this->getCommandName());
     return $context;
 }