[
https://issues.apache.org/jira/browse/FLINK-39365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18069835#comment-18069835
]
Ruan Hang commented on FLINK-39365:
-----------------------------------
Could you please change the title of this Jira ticket to English? This would
make it easier for community developers to communicate and discuss together.
Thanks. [~averyzhang]
> [CONNECTOR-HTTP] 支持自定义 HTTP HEADERS VIA CONFIGOPTION
> ----------------------------------------------------
>
> Key: FLINK-39365
> URL: https://issues.apache.org/jira/browse/FLINK-39365
> Project: Flink
> Issue Type: New Feature
> Components: Connectors / HTTP
> Reporter: featzhang
> Priority: Minor
>
> h2. Summary
> Custom HTTP headers configured via {{http.source.lookup.header.*}} and
> {{http.sink.header.*}} prefixes are consumed at runtime but never declared as
> typed {{ConfigOption}} definitions, causing Flink's factory validation to
> reject them with an "Unsupported options" error when specified in SQL DDL.
> h2. Problem
> Custom HTTP headers are read at runtime via
> {{HttpHeaderUtils.prepareHeaderMap()}} using raw property prefix scanning,
> but neither
> {{HttpLookupTableSourceFactory}} nor {{HttpDynamicTableSinkFactory}}
> declare these prefixed options in their {{optionalOptions()}}. This results
> in:
> # Users specifying custom headers in SQL DDL {{WITH}} clause receive a
> {{ValidationException}}
> # No type safety, default value enforcement, or IDE auto-completion
> # No official documentation entry for the feature
> h2. Steps to Reproduce
> {code:sql}
> CREATE TABLE http_lookup (
> id BIGINT,
> name STRING
> ) WITH (
> 'connector' = 'http',
> 'url' = 'http://localhost/api',
> 'format' = 'json',
> 'lookup-method' = 'POST',
> 'http.source.lookup.header.Content-Type' = 'application/json',
> 'http.source.lookup.header.Authorization' = 'Bearer my-token'
> );
> {code}
> *Result:*
> {noformat}
> org.apache.flink.table.api.ValidationException: Unsupported options found
> for 'http'.
> Unsupported options:
> http.source.lookup.header.Content-Type
> http.source.lookup.header.Authorization
> {noformat}
> h2. Fix
> # Define {{ConfigOption<Map<String, String>>}} for both:
> ** {{HttpLookupConnectorOptions.SOURCE_LOOKUP_HEADERS}} (key prefix:
> {{http.source.lookup.header}})
> ** {{HttpDynamicSinkConnectorOptions.SINK_HEADERS}} (key prefix:
> {{http.sink.header}})
> # Register both in {{optionalOptions()}} of their factory classes
> # Update documentation to describe the header configuration format
> Runtime behavior remains unchanged — headers continue to be read via the
> existing {{HttpHeaderUtils.prepareHeaderMap()}} mechanism.
> h2. Related
> * PR: https://github.com/apache/flink-connector-http/pull/32
--
This message was sent by Atlassian Jira
(v8.20.10#820010)