dsmiley commented on code in PR #3447:
URL: https://github.com/apache/solr/pull/3447#discussion_r2246832651
##########
solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java:
##########
@@ -736,107 +709,21 @@ void destroy() {
}
}
- // TODO using Http2Client
- private void remoteQuery(String coreUrl, HttpServletResponse resp) throws
IOException {
- HttpRequestBase method;
- HttpEntity httpEntity = null;
+ protected void sendRemoteQuery() throws IOException {
+ SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, new
SolrQueryResponse(), action));
+ mustClearSolrRequestInfo = true;
+
+ HttpClient httpClient = cores.getDefaultHttpSolrClient().getHttpClient();
ModifiableSolrParams updatedQueryParams = new
ModifiableSolrParams(queryParams);
int forwardCount = queryParams.getInt(INTERNAL_REQUEST_COUNT, 0) + 1;
updatedQueryParams.set(INTERNAL_REQUEST_COUNT, forwardCount);
String queryStr = updatedQueryParams.toQueryString();
try {
- String urlstr = coreUrl + queryStr;
-
- boolean isPostOrPutRequest = "POST".equals(req.getMethod()) ||
"PUT".equals(req.getMethod());
- if ("GET".equals(req.getMethod())) {
- method = new HttpGet(urlstr);
- } else if ("HEAD".equals(req.getMethod())) {
- method = new HttpHead(urlstr);
- } else if (isPostOrPutRequest) {
- HttpEntityEnclosingRequestBase entityRequest =
- "POST".equals(req.getMethod()) ? new HttpPost(urlstr) : new
HttpPut(urlstr);
- InputStream in = req.getInputStream();
- HttpEntity entity = new InputStreamEntity(in, req.getContentLength());
- entityRequest.setEntity(entity);
- method = entityRequest;
- } else if ("DELETE".equals(req.getMethod())) {
- method = new HttpDelete(urlstr);
- } else if ("OPTIONS".equals(req.getMethod())) {
- method = new HttpOptions(urlstr);
- } else {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR, "Unexpected method type: " +
req.getMethod());
- }
-
- for (Enumeration<String> e = req.getHeaderNames(); e.hasMoreElements();
) {
- String headerName = e.nextElement();
- if (!"host".equalsIgnoreCase(headerName)
- && !"authorization".equalsIgnoreCase(headerName)
- && !"accept".equalsIgnoreCase(headerName)) {
- method.addHeader(headerName, req.getHeader(headerName));
- }
- }
- // These headers not supported for HttpEntityEnclosingRequests
- if (method instanceof HttpEntityEnclosingRequest) {
- method.removeHeaders(TRANSFER_ENCODING_HEADER);
- method.removeHeaders(CONTENT_LENGTH_HEADER);
- }
-
- // Make sure the user principal is forwarded when its exist
- HttpClientContext httpClientRequestContext =
- HttpClientUtil.createNewHttpClientRequestContext();
- Principal userPrincipal = req.getUserPrincipal();
- if (userPrincipal != null) {
- // Normally the context contains a static userToken to enable reuse
resources. However, if a
- // personal Principal object exists, we use that instead, also as a
means to transfer
- // authentication information to Auth plugins that wish to intercept
the request later
- if (log.isDebugEnabled()) {
- log.debug("Forwarding principal {}", userPrincipal);
- }
- httpClientRequestContext.setUserToken(userPrincipal);
- }
Review Comment:
Out of curiosity, on main (not this PR), I locally removed the 3 header
exceptions and also removed the code above that you added to formerly propagate
the principal. Your new test fails... not sure why.
--
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]