目录

http_interceptor_type.h

Overview

Defines the data structures for the C APIs of the global HTTP interceptor module, including the interceptor request/response header information, HTTP request/response data packet structure, interceptor configuration information, and related enum types and function pointers.

Header file: <network/netstack/http_interceptor_type.h>

Library: libhttp_interceptor.so

System capability: SystemCapability.Communication.NetStack

Since: 24

Related module: netstack

Summary

[h2]Structs

Name typedef Keyword Description
OH_Http_Interceptor_Headers OH_Http_Interceptor_Headers Defines a struct for the request/response header information of the interceptor.
OH_Http_Interceptor_Request OH_Http_Interceptor_Request Defines a struct for the HTTP request data packet of the interceptor.
OH_Http_Interceptor_Response OH_Http_Interceptor_Response Defines a struct for the HTTP response data packet of the interceptor.
OH_Http_Interceptor OH_Http_Interceptor Defines a struct for the configuration information of the HTTP global interceptor.

[h2]Enums

Name typedef Keyword Description
OH_Interceptor_Stage OH_Interceptor_Stage Defines an enum for the interceptor stages.
OH_Interceptor_Type OH_Interceptor_Type Defines an enum for the interceptor types.
OH_Interceptor_Result OH_Interceptor_Result Defines an enum for the interceptor results.

[h2]Functions

Enum Description

[h2]OH_Interceptor_Stage

enum OH_Interceptor_Stage

Description

Defines an enum for the interceptor stages.

Since: 24

Parameters

Enum Item Description
OH_STAGE_REQUEST The interceptor processes the request.
OH_STAGE_RESPONSE The interceptor processes the response.

[h2]OH_Interceptor_Type

enum OH_Interceptor_Type

Description

Defines an enum for the interceptor types.

Parameters

Enum Item Description
OH_TYPE_READ_ONLY Read-only interceptor. Since: 24.
OH_TYPE_MODIFY_NETWORK_KIT Modifiable interceptor. Only effective for Network Kit HTTP requests. Since: 26.0.0.

[h2]OH_Interceptor_Result

enum OH_Interceptor_Result

Description

Defines an enum for the interceptor results.

Since: 24

Parameters

Enum Item Description
OH_CONTINUE The processing continues.
OH_ABORT The processing is aborted.

Function Description

[h2]OH_Http_InterceptorHandler()

typedef OH_Interceptor_Result (*OH_Http_InterceptorHandler)(
    OH_Http_Interceptor_Request *request,
    OH_Http_Interceptor_Response *response,
    int32_t *isModified)

Description

Defines the HTTP interceptor handler function.

Since: 24

Parameters

Name Description
OH_Http_Interceptor_Request *request Pointer to the HTTP request packet (valid only during the request phase).
OH_Http_Interceptor_Response *response Pointer to the HTTP response packet (valid only during the response phase).
int32_t *isModified

Pointer to whether the interceptor has modified the packet. This is invalid for OH_TYPE_READ_ONLY interceptors and can be set to nullptr.

- 0 indicates that no modification has been performed on the data.

- Non-0 values indicate that modification has been performed on the data.

Returns

Type Description
OH_Interceptor_Result

Interceptor processing result.

- OH_CONTINUE: continue processing

- OH_ABORT: abort processing