You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "epugh (via GitHub)" <gi...@apache.org> on 2026/09/25 23:16:30 UTC

[PR] SOLR-18483: Remove assumptions around wt, enabling v2 apis to communicate using headers [solr]

epugh opened a new pull request, #4946:
URL: https://github.com/apache/solr/pull/4946

   https://issues.apache.org/jira/browse/SOLR-18483
   
   # Description
   
   `wt` support was still in our v2 apis with a todo to remove it.  Removing it uncovered some assumptions about how solrj communicates with the server, it should use the `accept-content` header, but continue to use `wt`.   
   
   # Solution
   
   Refactoring with Claude the use of wt and the accept headers.   Now the various solrj clients actually send accept headers.
   
   # Tests
   
   mostly removed things!     I don't know if we need more integration tests?   
   


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18483: Remove assumptions around wt, enabling v2 apis to communicate using headers [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4946:
URL: https://github.com/apache/solr/pull/4946#discussion_r4109321962


##########
solr/core/src/java/org/apache/solr/jersey/MediaTypeOverridingFilter.java:
##########
@@ -50,8 +50,8 @@ public void filter(
       ContainerRequestContext requestContext, ContainerResponseContext responseContext)
       throws IOException {
 
-    // Solr has historically ignored 'wt' for client or server error responses, so maintain that
-    // behavior here for compatibility.
+    // Solr has historically ignored client/server error responses here, so maintain that

Review Comment:
   i don't know what to think about this.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18483: Remove assumptions around wt, enabling v2 apis to communicate using headers [solr]

Posted by "epugh (via GitHub) via issues" <is...@solr.apache.org>.
epugh commented on PR #4946:
URL: https://github.com/apache/solr/pull/4946#issuecomment-6757134522

   Responded to jira comments


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18483: Remove assumptions around wt, enabling v2 apis to communicate using headers [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4946:
URL: https://github.com/apache/solr/pull/4946#discussion_r4109325282


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java:
##########
@@ -163,6 +165,39 @@ protected ModifiableSolrParams initializeSolrParams(
     return params;
   }
 
+  // ResponseParser#getContentTypes() is contractually stable per parser (same Set instance every
+  // call), so the 'Accept' header derived from it is cacheable; this avoids rebuilding the same
+  // joined string on every request. Bounded in size by the number of distinct ResponseParser
+  // content-type sets in the JVM, which is small and fixed.
+  private static final Map<Collection<String>, String> ACCEPT_HEADER_CACHE =
+      new ConcurrentHashMap<>();
+
+  /**
+   * The 'Accept' header value that requests the response format {@code parserToUse} can read, or
+   * {@code null} if the parser doesn't care (in which case no 'Accept' header is added, and the
+   * server picks its own default -- currently JSON for v2 APIs).
+   */
+  protected static String acceptHeaderFor(ResponseParser parserToUse) {
+    final Collection<String> contentTypes = parserToUse.getContentTypes();
+    if (contentTypes.isEmpty()) {
+      return null;
+    }
+    return ACCEPT_HEADER_CACHE.computeIfAbsent(contentTypes, ct -> String.join(", ", ct));
+  }
+
+  /** Case-insensitive check for whether {@code headers} already specifies {@code name}. */
+  protected static boolean hasHeader(Map<String, String> headers, String name) {

Review Comment:
   it so wereid about the case snsitivity thing, and we don' have anything better?



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18483: Remove assumptions around wt, enabling v2 apis to communicate using headers [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4946:
URL: https://github.com/apache/solr/pull/4946#discussion_r4109320976


##########
solr/core/src/java/org/apache/solr/jersey/MediaTypeOverridingFilter.java:
##########
@@ -32,12 +30,14 @@
 import java.util.List;
 import org.apache.solr.api.JerseyResource;
 import org.apache.solr.handler.admin.ZookeeperRead;
-import org.apache.solr.handler.api.V2ApiUtils;
-import org.apache.solr.request.SolrQueryRequest;
 
-// TODO Deprecate or remove support for the 'wt' parameter in the v2 APIs in favor of the more
-//  HTTP-compliant 'Accept' header
-/** Overrides the content-type of the response based on an optional user-provided 'wt' parameter */
+/**
+ * Defaults the response content-type to JSON, unless the client requested something else via the
+ * (HTTP-compliant) 'Accept' header.
+ *
+ * <p>v2 APIs do not honor the legacy 'wt' parameter for response-format selection -- 'Accept' is

Review Comment:
   maybe still useful comment till we eliminate v1.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org