OSS\OssClient::optionsObject PHP Метод

optionsObject() публичный Метод

检验跨域资源请求, 发送跨域请求之前会发送一个preflight请求(OPTIONS)并带上特定的来源域, HTTP方法和header信息等给OSS以决定是否发送真正的请求。 OSS可以通过putBucketCors接口 来开启Bucket的CORS支持,开启CORS功能之后,OSS在收到浏览器preflight请求时会根据设定的 规则评估是否允许本次请求
public optionsObject ( string $bucket, string $object, string $origin, string $request_method, string $request_headers, array $options = NULL ) : array
$bucket string bucket名称
$object string object名称
$origin string 请求来源域
$request_method string 表明实际请求中会使用的HTTP方法
$request_headers string 表明实际请求中会使用的除了简单头部之外的headers
$options array
Результат array
    public function optionsObject($bucket, $object, $origin, $request_method, $request_headers, $options = NULL)
    {
        $this->precheckCommon($bucket, NULL, $options, false);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = self::OSS_HTTP_OPTIONS;
        $options[self::OSS_OBJECT] = $object;
        $options[self::OSS_HEADERS] = array(self::OSS_OPTIONS_ORIGIN => $origin, self::OSS_OPTIONS_REQUEST_HEADERS => $request_headers, self::OSS_OPTIONS_REQUEST_METHOD => $request_method);
        $response = $this->auth($options);
        $result = new HeaderResult($response);
        return $result->getData();
    }