Details
-
New Feature
-
Status: Resolved
-
Minor
-
Resolution: Duplicate
-
1.4
-
None
-
None
-
None
Description
I am implementing several custom request handlers and response writers. All of them need access to HTTP headers and cookies. In scanning google for mailing lists and forums it seems others have had this same need.
I worked around it by creating a custom dispatch filter which extends SolrDispatchFilter and does the following:
public static final String CONTEXT_SERVLET_REQUEST = "servletRequest"; public static final String CONTEXT_SERVLET_RESPONSE = "servletResponse"; @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setAttribute("response", response); super.doFilter(request, response, chain); } @Override protected void execute(HttpServletRequest servletRequest, SolrRequestHandler handler, SolrQueryRequest solrRequest, SolrQueryResponse solrResponse) { Object servletResponse = servletRequest.getAttribute("response"); servletRequest.removeAttribute("response"); solrRequest.getContext().put(CONTEXT_SERVLET_REQUEST, servletRequest); solrRequest.getContext().put(CONTEXT_SERVLET_RESPONSE, servletResponse); super.execute(servletRequest, handler, solrRequest, solrResponse); }
I then had to write a step in my deployment script to crack open the solr war file, sed the web.xml and replace the SolrDispatchFilter with my own. Others have worked around the issue in the same way. This seems like an ugly workaround and would be simpler and cleaner if the SolrQueryRequest and SolrQueryResponse just included a reference to their http counterparts.
Attachments
Attachments
Issue Links
- duplicates
-
SOLR-2079 Expose HttpServletRequest object from SolrQueryRequest object
- Closed