You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2022/02/12 17:20:54 UTC

[solr] branch branch_9x updated (5de92fc -> adbb9c4)

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

epugh pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git.


    from 5de92fc  SOLR-15974: Remove Calcite's ENUMERABLE_AGGREGATE_RULE as Solr only supports push-down for LogicalAggregate (#626) (#627)
     new 4904684  SOLR-15116: track changes
     new adbb9c4  SOLR-15116: Support a HEAD request for managed resources (#495)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   |  2 ++
 .../src/java/org/apache/solr/rest/RestManager.java | 15 ++++++++++++
 .../solr/response/TestSolrQueryResponse.java       | 28 ++++++++++++++++++++++
 3 files changed, 45 insertions(+)

[solr] 02/02: SOLR-15116: Support a HEAD request for managed resources (#495)

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit adbb9c49f39175f1d45ca616ade16a5e56311b3f
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Sat Feb 12 18:16:28 2022 +0100

    SOLR-15116: Support a HEAD request for managed resources (#495)
    
    * Now support the HEAD verb by doing normal GET and then dropping the response body.
---
 .../src/java/org/apache/solr/rest/RestManager.java | 15 ++++++++++++
 .../solr/response/TestSolrQueryResponse.java       | 28 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/solr/core/src/java/org/apache/solr/rest/RestManager.java b/solr/core/src/java/org/apache/solr/rest/RestManager.java
index ea1d3c0..7977cc4 100644
--- a/solr/core/src/java/org/apache/solr/rest/RestManager.java
+++ b/solr/core/src/java/org/apache/solr/rest/RestManager.java
@@ -42,6 +42,7 @@ import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.util.ContentStream;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
@@ -327,6 +328,10 @@ public class RestManager {
       final String method = req.getHttpMethod();
       try {
         switch (method) {
+          case "HEAD":
+            managedResource.doGet(this, childId);
+            doHead(this);
+            break;
           case "GET":
             managedResource.doGet(this, childId);
             break;
@@ -346,6 +351,16 @@ public class RestManager {
       handlePostExecution(log);
     }
 
+    private void doHead(ManagedEndpoint managedEndpoint) {
+      // Setting the response to blank clears the content out,
+      // however it also means the Content-Length HTTP Header is set to 0
+      // which isn't compliant with the specification of how HEAD should work,
+      // it should instead return the length of the content if you did a GET.
+      NamedList<Object> blank = new SimpleOrderedMap<>();
+      managedEndpoint.getSolrResponse().setAllValues(blank);
+
+    }
+
     protected void doDelete() {
       // only delegate delete child resources to the ManagedResource
       // as deleting the actual resource is best handled by the
diff --git a/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java b/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
index 66aca82..f658158 100644
--- a/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
+++ b/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
@@ -289,4 +289,32 @@ public class TestSolrQueryResponse extends SolrTestCase {
     assertEquals("httpCaching new value", newValue, response.isHttpCaching());
   }
 
+  @Test
+  public void testConvertToHEADStyleResponse() throws Exception {
+    final SolrQueryResponse response = new SolrQueryResponse();
+    final NamedList<Object> newValue = new SimpleOrderedMap<>();
+    newValue.add("responseHeaderKey1", "value1");
+    response.add("responseHeaderKey2", "value2");
+    response.addResponseHeader(newValue);
+
+    response.addResponse("foo");
+    response.add("bob", "dole");
+
+    response.addHttpHeader("key1", "value1");
+
+    NamedList<Object> blank = new SimpleOrderedMap<>();
+    response.setAllValues(blank);
+
+    Iterator<Entry<String, String>> it = response.httpHeaders();
+    assertTrue(it.hasNext());
+    Entry<String, String> entry = it.next();
+    assertEquals("key1", entry.getKey());
+    assertEquals("value1", entry.getValue());
+    assertFalse(it.hasNext());
+
+
+
+
+  }
+
 }

[solr] 01/02: SOLR-15116: track changes

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4904684561e0e4f79b9d304f7ba5f71cc1a290b3
Author: epugh@opensourceconnections.com <>
AuthorDate: Sat Feb 12 18:18:58 2022 +0100

    SOLR-15116: track changes
---
 solr/CHANGES.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d39d45b..1ae2d86 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -26,6 +26,8 @@ Bug Fixes
 
 * SOLR-15964: Transient cores: don't evict a core when it's still being used. (David Smiley)
 
+* SOLR-15116: Support a HEAD request for managed resources. (Eric Pugh)
+
 Other Changes
 ---------------------
 * SOLR-15897: Remove <jmx/> from all unit test solrconfig.xml files. (Eric Pugh)