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

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 0b85977d73d SOLR-17741: Remove addHttpRequestToContext option (#3325)
0b85977d73d is described below

commit 0b85977d73d49b86c18590a64a6b5c603f73009b
Author: David Smiley <[email protected]>
AuthorDate: Sun Apr 20 23:26:44 2025 +0900

    SOLR-17741: Remove addHttpRequestToContext option (#3325)
    
    In solrconfig.xml/requestDispatcher/requestParsers.
    Why: Obsolete/redundant with SolrQueryRequest.getHttpSolrCall().getReq()
    
    * config overlay: remove 2 old/obsolete options: enableRemoteStreaming & 
enableStreamBody
---
 .../src/java/org/apache/solr/core/SolrConfig.java  | 11 +-------
 .../apache/solr/servlet/SolrRequestParsers.java    | 17 ------------
 .../resources/EditableSolrConfigAttributes.json    |  5 +---
 .../org/apache/solr/core/TestConfigOverlay.java    |  5 ----
 .../apache/solr/core/TestSolrConfigHandler.java    |  5 ++--
 .../apache/solr/servlet/SolrRequestParserTest.java | 31 ----------------------
 .../solr/configsets/_default/conf/solrconfig.xml   | 10 +------
 .../conf/solrconfig.xml                            |  9 +------
 .../configuration-guide/pages/config-api.adoc      |  1 -
 .../pages/requestdispatcher.adoc                   | 12 +--------
 .../pages/major-changes-in-solr-10.adoc            |  3 +++
 11 files changed, 10 insertions(+), 99 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java 
b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index 968b7aa51f5..4034fb42e2a 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -130,8 +130,6 @@ public class SolrConfig implements MapSerializable {
 
   private boolean handleSelect;
 
-  private boolean addHttpRequestToContext;
-
   private final SolrRequestParsers solrRequestParsers;
 
   /**
@@ -366,7 +364,6 @@ public class SolrConfig implements MapSerializable {
       }
 
       handleSelect = get("requestDispatcher").boolAttr("handleSelect", false);
-      addHttpRequestToContext = 
requestParsersNode.boolAttr("addHttpRequestToContext", false);
 
       List<PluginInfo> argsInfos = getPluginInfos(InitParams.class.getName());
       if (argsInfos != null) {
@@ -961,10 +958,6 @@ public class SolrConfig implements MapSerializable {
     return handleSelect;
   }
 
-  public boolean isAddHttpRequestToContext() {
-    return addHttpRequestToContext;
-  }
-
   @Override
   public Map<String, Object> toMap(Map<String, Object> result) {
     if (znodeVersion > -1) result.put(ZNODEVER, znodeVersion);
@@ -1020,9 +1013,7 @@ public class SolrConfig implements MapSerializable {
             "multipartUploadLimitKB",
             multipartUploadLimitKB,
             "formUploadLimitKB",
-            formUploadLimitKB,
-            "addHttpRequestToContext",
-            addHttpRequestToContext));
+            formUploadLimitKB));
     if (indexConfig != null) result.put("indexConfig", indexConfig);
 
     // TODO there is more to add
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java 
b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
index ee2aa66a468..44db73a92e1 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
@@ -88,7 +88,6 @@ public class SolrRequestParsers {
   private final boolean enableStreamBody;
   private StandardRequestParser standard;
   private boolean handleSelect = true;
-  private boolean addHttpRequestToContext;
 
   /**
    * Default instance for e.g. admin requests. Limits to 2 MB uploads and does 
not allow remote
@@ -106,7 +105,6 @@ public class SolrRequestParsers {
       enableRemoteStreams = false;
       enableStreamBody = false;
       handleSelect = false;
-      addHttpRequestToContext = false;
     } else {
       multipartUploadLimitKB = globalConfig.getMultipartUploadLimitKB();
 
@@ -118,8 +116,6 @@ public class SolrRequestParsers {
 
       // Let this filter take care of /select?xxx format
       handleSelect = globalConfig.isHandleSelect();
-
-      addHttpRequestToContext = globalConfig.isAddHttpRequestToContext();
     }
     init(multipartUploadLimitKB, formUploadLimitKB);
   }
@@ -128,7 +124,6 @@ public class SolrRequestParsers {
     enableRemoteStreams = false;
     enableStreamBody = false;
     handleSelect = false;
-    addHttpRequestToContext = false;
     init(Integer.MAX_VALUE, Integer.MAX_VALUE);
   }
 
@@ -174,10 +169,6 @@ public class SolrRequestParsers {
     // the handler could use it for RESTful URLs
     sreq.getContext().put(PATH, RequestHandlers.normalize(path));
     sreq.getContext().put("httpMethod", req.getMethod());
-
-    if (addHttpRequestToContext) {
-      sreq.getContext().put("httpRequest", req);
-    }
     return sreq;
   }
 
@@ -533,14 +524,6 @@ public class SolrRequestParsers {
     this.handleSelect = handleSelect;
   }
 
-  public boolean isAddRequestHeadersToContext() {
-    return addHttpRequestToContext;
-  }
-
-  public void setAddRequestHeadersToContext(boolean 
addRequestHeadersToContext) {
-    this.addHttpRequestToContext = addRequestHeadersToContext;
-  }
-
   public boolean isEnableRemoteStreams() {
     return enableRemoteStreams;
   }
diff --git a/solr/core/src/resources/EditableSolrConfigAttributes.json 
b/solr/core/src/resources/EditableSolrConfigAttributes.json
index 5d67b88afe6..0d65f2e3853 100644
--- a/solr/core/src/resources/EditableSolrConfigAttributes.json
+++ b/solr/core/src/resources/EditableSolrConfigAttributes.json
@@ -59,8 +59,5 @@
     "handleSelect":0,
     "requestParsers":{
       "multipartUploadLimitInKB":0,
-      "formdataUploadLimitInKB":0,
-      "enableRemoteStreaming":10,
-      "enableStreamBody":10,
-      "addHttpRequestToContext":0}},
+      "formdataUploadLimitInKB":0}}
 }
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java 
b/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
index e0d0d62b81e..c9da5383fd9 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
@@ -48,11 +48,6 @@ public class TestConfigOverlay extends SolrTestCase {
         
isEditableProp("requestDispatcher.requestParsers.multipartUploadLimitInKB", 
false, null));
     assertTrue(
         
isEditableProp("requestDispatcher.requestParsers.formdataUploadLimitInKB", 
false, null));
-    assertTrue(
-        
isEditableProp("requestDispatcher.requestParsers.enableRemoteStreaming", false, 
null));
-    
assertTrue(isEditableProp("requestDispatcher.requestParsers.enableStreamBody", 
false, null));
-    assertTrue(
-        
isEditableProp("requestDispatcher.requestParsers.addHttpRequestToContext", 
false, null));
 
     assertTrue(isEditableProp("requestDispatcher.handleSelect", false, null));
 
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java 
b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
index 9591d28bba1..c9a16e26d5a 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
@@ -160,7 +160,7 @@ public class TestSolrConfigHandler extends RestTestBase {
 
     String payload =
         "{\n"
-            + " 'set-property' : { 'updateHandler.autoCommit.maxDocs':100, 
'updateHandler.autoCommit.maxTime':10 , 
'requestDispatcher.requestParsers.addHttpRequestToContext':true} \n"
+            + " 'set-property' : { 'updateHandler.autoCommit.maxDocs':100, 
'updateHandler.autoCommit.maxTime':10 } \n"
             + " }";
     runConfigCommand(harness, "/config", payload);
 
@@ -178,8 +178,7 @@ public class TestSolrConfigHandler extends RestTestBase {
 
     assertEquals("100", m._getStr("config/updateHandler/autoCommit/maxDocs", 
null));
     assertEquals("10", m._getStr("config/updateHandler/autoCommit/maxTime", 
null));
-    assertEquals(
-        "true", 
m._getStr("config/requestDispatcher/requestParsers/addHttpRequestToContext", 
null));
+
     payload = "{\n" + " 'unset-property' :  'updateHandler.autoCommit.maxDocs' 
\n" + " }";
     runConfigCommand(harness, "/config", payload);
 
diff --git 
a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java 
b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
index f2634411e90..0937a432efd 100644
--- a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
+++ b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
@@ -34,7 +34,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 import javax.servlet.ReadListener;
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -409,36 +408,6 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     verify(request).getInputStream();
   }
 
-  @Test
-  @SuppressWarnings("JdkObsolete")
-  public void testAddHttpRequestToContext() throws Exception {
-    HttpServletRequest request = getMock("/solr/select", null, -1);
-    when(request.getMethod()).thenReturn("GET");
-    when(request.getQueryString()).thenReturn("q=title:solr");
-    Map<String, String> headers = new HashMap<>();
-    headers.put("X-Forwarded-For", "10.0.0.1");
-    when(request.getHeaderNames()).thenReturn(new 
Vector<>(headers.keySet()).elements());
-    for (Map.Entry<String, String> entry : headers.entrySet()) {
-      Vector<String> v = new Vector<>();
-      v.add(entry.getValue());
-      when(request.getHeaders(entry.getKey())).thenReturn(v.elements());
-    }
-
-    SolrRequestParsers parsers = new 
SolrRequestParsers(h.getCore().getSolrConfig());
-    assertFalse(parsers.isAddRequestHeadersToContext());
-    SolrQueryRequest solrReq = parsers.parse(h.getCore(), "/select", request);
-    assertFalse(solrReq.getContext().containsKey("httpRequest"));
-
-    parsers.setAddRequestHeadersToContext(true);
-    solrReq = parsers.parse(h.getCore(), "/select", request);
-    assertEquals(request, solrReq.getContext().get("httpRequest"));
-    assertEquals(
-        "10.0.0.1",
-        ((HttpServletRequest) solrReq.getContext().get("httpRequest"))
-            .getHeaders("X-Forwarded-For")
-            .nextElement());
-  }
-
   public void testPostMissingContentType() throws Exception {
     HttpServletRequest request = getMock();
     when(request.getMethod()).thenReturn("POST");
diff --git a/solr/server/solr/configsets/_default/conf/solrconfig.xml 
b/solr/server/solr/configsets/_default/conf/solrconfig.xml
index 4ca8a8db187..03d7ed2924a 100644
--- a/solr/server/solr/configsets/_default/conf/solrconfig.xml
+++ b/solr/server/solr/configsets/_default/conf/solrconfig.xml
@@ -526,16 +526,8 @@
          POST. You can use POST to pass request parameters not
          fitting into the URL.
 
-         addHttpRequestToContext - if set to true, it will instruct
-         the requestParsers to include the original HttpServletRequest
-         object in the context map of the SolrQueryRequest under the
-         key "httpRequest". It will not be used by any of the existing
-         Solr components, but may be useful when developing custom
-         plugins.
-
     <requestParsers multipartUploadLimitInKB="-1"
-                    formdataUploadLimitInKB="-1"
-                    addHttpRequestToContext="false"/>
+                    formdataUploadLimitInKB="-1"/>
       -->
 
     <!-- HTTP Caching
diff --git 
a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml 
b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
index 194d7e5dfe5..a9fee35f5d6 100644
--- 
a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
+++ 
b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
@@ -538,17 +538,10 @@
          POST. You can use POST to pass request parameters not
          fitting into the URL.
 
-         addHttpRequestToContext - if set to true, it will instruct
-         the requestParsers to include the original HttpServletRequest
-         object in the context map of the SolrQueryRequest under the
-         key "httpRequest". It will not be used by any of the existing
-         Solr components, but may be useful when developing custom
-         plugins.
        -->
     <requestParsers
                     multipartUploadLimitInKB="-1"
-                    formdataUploadLimitInKB="-1"
-                    addHttpRequestToContext="false"/>
+                    formdataUploadLimitInKB="-1"/>
 
     <!-- HTTP Caching
 
diff --git 
a/solr/solr-ref-guide/modules/configuration-guide/pages/config-api.adoc 
b/solr/solr-ref-guide/modules/configuration-guide/pages/config-api.adoc
index 05b2c490374..6bf03f30d47 100644
--- a/solr/solr-ref-guide/modules/configuration-guide/pages/config-api.adoc
+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/config-api.adoc
@@ -222,7 +222,6 @@ See xref:requestdispatcher.adoc[] for defaults and 
acceptable values for these s
 * `requestDispatcher.handleSelect`
 * `requestDispatcher.requestParsers.multipartUploadLimitInKB`
 * `requestDispatcher.requestParsers.formdataUploadLimitInKB`
-* `requestDispatcher.requestParsers.addHttpRequestToContext`
 
 ==== Examples of Common Properties
 
diff --git 
a/solr/solr-ref-guide/modules/configuration-guide/pages/requestdispatcher.adoc 
b/solr/solr-ref-guide/modules/configuration-guide/pages/requestdispatcher.adoc
index ecc97008218..70cdc8fad97 100644
--- 
a/solr/solr-ref-guide/modules/configuration-guide/pages/requestdispatcher.adoc
+++ 
b/solr/solr-ref-guide/modules/configuration-guide/pages/requestdispatcher.adoc
@@ -69,21 +69,11 @@ A value of `-1` means MAX_INT, which is also the system 
default if omitted.
 This attribute sets a limit in kilobytes on the size of form data 
(`application/x-www-form-urlencoded`) submitted in a HTTP POST request, which 
can be used to pass request parameters that will not fit in a URL.
 A value of `-1` means MAX_INT, which is also the system default if omitted.
 
-`addHttpRequestToContext`::
-+
-[%autowidth,frame=none]
-|===
-|Optional |Default: none
-|===
-+
-This attribute can be used to indicate that the original `HttpServletRequest` 
object should be included in the context map of the `SolrQueryRequest` using 
the key `httpRequest`.
-This `HttpServletRequest` is not used by any Solr component, but may be useful 
when developing custom plugins.
 
 [source,xml]
 ----
 <requestParsers multipartUploadLimitInKB="2048"
-                formdataUploadLimitInKB="2048"
-                addHttpRequestToContext="false" />
+                formdataUploadLimitInKB="2048" />
 ----
 
 == httpCaching Element
diff --git 
a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc 
b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
index 618fc5f6e0b..365bef4558d 100644
--- 
a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
+++ 
b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
@@ -111,6 +111,9 @@ Users who that don't need to vary JAR access on a per-core 
basis have several op
 
 * CurrencyField has been removed.  Users should migrate to the 
`CurrencyFieldType` implementation.
 
+* The `addHttpRequestToContext` option in `solrconfig.xml` has been removed; 
it's obsolete.
+Nowadays, the HTTP request is available via internal APIs: 
`SolrQueryRequest.getHttpSolrCall().getReq()`.
+
 === Security
 
 * There is no longer a distinction between trusted and untrusted configSets; 
all configSets are now considered trusted. To ensure security, Solr should be 
properly protected using authentication and authorization mechanisms, allowing 
only authorized users with administrative privileges to publish them.

Reply via email to