epugh commented on code in PR #4080:
URL: https://github.com/apache/solr/pull/4080#discussion_r2733933765
##########
solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java:
##########
@@ -200,12 +201,55 @@ default QueryResponseWriter getResponseWriter() {
// it's weird this method is here instead of SolrQueryResponse, but it's
practical/convenient
SolrCore core = getCore();
String wt = getParams().get(CommonParams.WT);
+
+ if (wt == null || wt.isEmpty()) {
+ // Fall back to Accept header if wt parameter is not provided
+ wt = getWtFromAcceptHeader();
+ }
+
+ QueryResponseWriter writer;
if (core != null) {
- return core.getQueryResponseWriter(wt);
+ writer = core.getQueryResponseWriter(wt);
} else {
- return SolrCore.DEFAULT_RESPONSE_WRITERS.getOrDefault(
- wt, SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard"));
+ writer = SolrCore.DEFAULT_RESPONSE_WRITERS.get(wt);
+ }
+ if (writer == null) {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Unknown response writer type:
" + wt);
+ }
+ return writer;
+ }
+
+ /**
+ * Maps the HTTP Accept header to a wt parameter value. Returns "json" as
default if no Accept
+ * header is present or if the content type is not recognized.
+ *
+ * <p>This is a quick implmentation, but it's not pluggable. For example,
how do we support CBOR
+ * without modifying this. In V2ApiUtils.getMediaTypeFromWtParam() we do the
same basic thing. i
+ * also dont' see cbor.
+ *
Review Comment:
fair
--
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]