FrankChen021 commented on code in PR #20268:
URL: https://github.com/apache/druid/pull/20268#discussion_r3940723330


##########
server/src/main/java/org/apache/druid/server/initialization/jetty/ResponseIdentityHeaderHandler.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server.initialization.jetty;
+
+import org.apache.druid.server.DruidNode;
+import org.eclipse.jetty.client.Response;
+import org.eclipse.jetty.http.HttpField;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.rewrite.handler.HeaderPatternRule;
+import org.eclipse.jetty.rewrite.handler.RewriteHandler;
+import org.eclipse.jetty.server.Handler;
+
+import javax.servlet.http.HttpServletResponse;
+
+public class ResponseIdentityHeaderHandler extends RewriteHandler
+{
+  public static final String RESPONSE_SERVER_HEADER = "X-Druid-Server";
+  public static final String RESPONSE_SERVICE_HEADER = "X-Druid-Service";
+  public static final String RESPONSE_VERSION_HEADER = "X-Druid-Version";
+
+  public ResponseIdentityHeaderHandler(final DruidNode selfNode, final Handler 
handler)
+  {
+    super(handler);
+    addRule(new HeaderPatternRule("*", RESPONSE_SERVER_HEADER, 
selfNode.getHostAndPortToUse()));

Review Comment:
   Fixed in 180c4466c6. ResponseIdentityHeaderHandler now wraps the mutable 
header collection so servlet-level header clears re-add the complete identity 
triple, while retaining core Response.reset() handling. 
ResponseIdentityHeaderHandlerTest exercises both getHeaders().clear() and 
reset().



##########
server/src/main/java/org/apache/druid/server/initialization/ServerConfig.java:
##########
@@ -206,6 +206,9 @@ public ServerConfig(@NotNull ErrorResponseTransformStrategy 
errorResponseTransfo
   @JsonProperty
   private boolean enableHSTS = false;
 
+  @JsonProperty
+  private boolean enableResponseIdentityHeaders = false;

Review Comment:
   Fixed in 180c4466c6. The flag-aware ServerConfig constructor is now used by 
CliIndexerServerModule.makeAdjustedServerConfig, which copies 
enableResponseIdentityHeaders; the prior public constructor signature remains 
available for compatibility. CliIndexerServerModuleTest covers preservation of 
the enabled flag.



##########
server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java:
##########
@@ -404,6 +404,9 @@ public void lifeCycleStopped(LifeCycle event)
     JettyServerInitializer initializer = 
injector.getInstance(JettyServerInitializer.class);
     try {
       initializer.initialize(server, injector);
+      if (config.isEnableResponseIdentityHeaders()) {
+        server.setHandler(new ResponseIdentityHeaderHandler(node, 
server.getHandler()));

Review Comment:
   Fixed in 180c4466c6. OverlordProxyServlet now clears the Coordinator 
identity before upstream response handling and applies the same 
enabled-and-complete-triple filter as the Router proxies. Unit tests cover 
complete, partial, and disabled cases, and ResponseIdentityHeaderTest exercises 
a real separate Coordinator-to-Overlord proxy request.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to