This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new dfcb76bd9f [rest] fix base header options in RESTApi (#5810)
dfcb76bd9f is described below

commit dfcb76bd9fe5097bf658323dc6296e5a097dcacc
Author: shyjsarah <[email protected]>
AuthorDate: Fri Jun 27 19:48:57 2025 +0800

    [rest] fix base header options in RESTApi (#5810)
---
 .../src/main/java/org/apache/paimon/rest/RESTApi.java   |  3 +--
 .../org/apache/paimon/rest/MockRESTCatalogTest.java     | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java 
b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
index e615ca99db..5af953eb85 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
@@ -177,14 +177,13 @@ public class RESTApi {
     public RESTApi(Options options, boolean configRequired) {
         this.client = new HttpClient(options.get(RESTCatalogOptions.URI));
         AuthProvider authProvider = createAuthProvider(options);
-        Map<String, String> baseHeaders = Collections.emptyMap();
+        Map<String, String> baseHeaders = extractPrefixMap(options, 
HEADER_PREFIX);
         if (configRequired) {
             String warehouse = options.get(WAREHOUSE);
             Map<String, String> queryParams =
                     StringUtils.isNotEmpty(warehouse)
                             ? ImmutableMap.of(WAREHOUSE.key(), 
RESTUtil.encodeString(warehouse))
                             : ImmutableMap.of();
-            baseHeaders = extractPrefixMap(options, HEADER_PREFIX);
             options =
                     new Options(
                             client.get(
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTCatalogTest.java
index cc420a73e9..a6e1936f40 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTCatalogTest.java
@@ -48,6 +48,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import static org.apache.paimon.rest.RESTApi.HEADER_PREFIX;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
@@ -151,6 +152,22 @@ class MockRESTCatalogTest extends RESTCatalogTest {
         assertEquals(headers.get(serverDefineHeaderName), 
serverDefineHeaderValue);
     }
 
+    @Test
+    void testHeaderOptions() throws Exception {
+        options.set(HEADER_PREFIX + "User-Agent", "test");
+        RESTCatalog restCatalog = initCatalog(false);
+
+        Map<String, String> parameters = new HashMap<>();
+        RESTAuthParameter restAuthParameter =
+                new RESTAuthParameter("/path", parameters, "method", "data");
+        Map<String, String> headers = 
restCatalog.api().authFunction().apply(restAuthParameter);
+        assertEquals(headers.get("User-Agent"), "test");
+
+        RESTCatalog restCatalog2 = restCatalog.catalogLoader().load();
+        Map<String, String> headers2 = 
restCatalog2.api().authFunction().apply(restAuthParameter);
+        assertEquals(headers2.get("User-Agent"), "test");
+    }
+
     private void testDlfAuth(RESTCatalog restCatalog) throws Exception {
         String databaseName = "db1";
         restCatalog.createDatabase(databaseName, true);

Reply via email to