全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

管理存储空间 HTTP/2 协议配置

最近更新时间:2026-07-28 15:02:28

设置 HTTP/2 协议配置

以下代码用于设置 HTTP/2 协议配置:

public void putBucketHttp2() {
    // 初始化 Ks3Client,参见"初始化"文档
    Ks3Client ks3Client = initKs3Client();

    try {
        String bucketName = "your-bucket-name";

        // 方式一:使用 Http2Configuration 对象设置
        ks3Client.putBucketHttp2(bucketName, new Http2Configuration(Status.ENABLED));

        // 方式二:使用 PutBucketHttp2Request 对象设置
        ks3Client.putBucketHttp2(new PutBucketHttp2Request(bucketName, Status.ENABLED));
        System.out.println("HTTP/2 协议配置设置成功");
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}

获取 HTTP/2 协议配置

以下代码用于获取 HTTP/2 协议配置:

public void getBucketHttp2() {
    // 初始化 Ks3Client,参见"初始化"文档
    Ks3Client ks3Client = initKs3Client();

    try {
        String bucketName = "your-bucket-name";

        // 获取 Bucket 的 HTTP/2 协议配置
        Http2Configuration http2Configuration = ks3Client.getBucketHttp2(bucketName);

        if (http2Configuration != null) {
            System.out.println("HTTP/2 协议状态: " + http2Configuration.getStatus());
            System.out.println("是否启用: " + (http2Configuration.getStatus() == Status.ENABLED));
        } else {
            System.out.println("未获取到 HTTP/2 协议配置");
        }
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}
文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈