You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Giovanni De Stefano <gi...@gmail.com> on 2009/04/09 14:57:22 UTC
Access HTTP headers from custom request handler
Hello all,
we are writing a custom request handler and we need to implement some
business logic according to some HTTP headers.
I see there is no easy way to access HTTP headers from the request handler.
Moreover it seems to me that the HTTPServletness is lost way before the
custom request handler comes in the game.
Is there any way to access HTTP headers from within the request handler?
Thanks,
Giovanni
Re: Access HTTP headers from custom request handler
Posted by Ryan McKinley <ry...@gmail.com>.
Right, you will have to build a new war with your own subclass of
SolrDispatchFilter *rather* then using the packaged one.
On Apr 23, 2009, at 12:34 PM, Noble Paul നോബിള്
नोब्ळ् wrote:
> nope.
> you must edit the web.xml and register the filter there
>
> On Thu, Apr 23, 2009 at 3:45 PM, Giovanni De Stefano
> <gi...@gmail.com> wrote:
>> Hello Hoss,
>>
>> thank you for your reply.
>>
>> I have no problems subclassing the SolrDispatchFilter...but where
>> shall I
>> configure it? :-)
>>
>> I cannot find any doc/wiki explaining how to configure a custom
>> dispatch
>> filter.
>>
>> I believe it should be in solrconfig.xml
>>
>> <requestDispatcher ...> ... </requestDispatcher>
>>
>> Any idea? Is there a schema for solrconfig.xml? It would make my life
>> easier... ;-)
>>
>> Thanks,
>> Giovanni
>>
>>
>>
>> On Wed, Apr 15, 2009 at 12:48 AM, Chris Hostetter
>> <ho...@fucit.org>wrote:
>>
>>>
>>> : Solr cannot assume that the request would always come from http
>>> (think
>>> : of EmbeddedSolrServer) .So it assumes that there are only
>>> parameters
>>>
>>> exactly.
>>>
>>> : Your best bet is to modify SolrDispatchFilter and readthe params
>>> and
>>> : set them in the SolrRequest Object
>>>
>>> SolrDispatchFilter is designed to be subclassed to make this easy by
>>> overriding the execute method...
>>>
>>> protected void execute( HttpServletRequest req, SolrRequestHandler
>>> handler,
>>> SolrQueryRequest sreq, SolrQueryResponse
>>> rsp) {
>>> sreq.getContext().put( "HttpServletRequest", req );
>>> super.execute( req, handler, sreq, rsp )
>>> }
>>>
>>> -Hoss
>>>
>>>
>>
>
>
>
> --
> --Noble Paul
Re: Access HTTP headers from custom request handler
Posted by Noble Paul നോബിള് नोब्ळ् <no...@gmail.com>.
nope.
you must edit the web.xml and register the filter there
On Thu, Apr 23, 2009 at 3:45 PM, Giovanni De Stefano
<gi...@gmail.com> wrote:
> Hello Hoss,
>
> thank you for your reply.
>
> I have no problems subclassing the SolrDispatchFilter...but where shall I
> configure it? :-)
>
> I cannot find any doc/wiki explaining how to configure a custom dispatch
> filter.
>
> I believe it should be in solrconfig.xml
>
> <requestDispatcher ...> ... </requestDispatcher>
>
> Any idea? Is there a schema for solrconfig.xml? It would make my life
> easier... ;-)
>
> Thanks,
> Giovanni
>
>
>
> On Wed, Apr 15, 2009 at 12:48 AM, Chris Hostetter
> <ho...@fucit.org>wrote:
>
>>
>> : Solr cannot assume that the request would always come from http (think
>> : of EmbeddedSolrServer) .So it assumes that there are only parameters
>>
>> exactly.
>>
>> : Your best bet is to modify SolrDispatchFilter and readthe params and
>> : set them in the SolrRequest Object
>>
>> SolrDispatchFilter is designed to be subclassed to make this easy by
>> overriding the execute method...
>>
>> protected void execute( HttpServletRequest req, SolrRequestHandler
>> handler,
>> SolrQueryRequest sreq, SolrQueryResponse rsp) {
>> sreq.getContext().put( "HttpServletRequest", req );
>> super.execute( req, handler, sreq, rsp )
>> }
>>
>> -Hoss
>>
>>
>
--
--Noble Paul
Re: Access HTTP headers from custom request handler
Posted by Giovanni De Stefano <gi...@gmail.com>.
Hello Hoss,
thank you for your reply.
I have no problems subclassing the SolrDispatchFilter...but where shall I
configure it? :-)
I cannot find any doc/wiki explaining how to configure a custom dispatch
filter.
I believe it should be in solrconfig.xml
<requestDispatcher ...> ... </requestDispatcher>
Any idea? Is there a schema for solrconfig.xml? It would make my life
easier... ;-)
Thanks,
Giovanni
On Wed, Apr 15, 2009 at 12:48 AM, Chris Hostetter
<ho...@fucit.org>wrote:
>
> : Solr cannot assume that the request would always come from http (think
> : of EmbeddedSolrServer) .So it assumes that there are only parameters
>
> exactly.
>
> : Your best bet is to modify SolrDispatchFilter and readthe params and
> : set them in the SolrRequest Object
>
> SolrDispatchFilter is designed to be subclassed to make this easy by
> overriding the execute method...
>
> protected void execute( HttpServletRequest req, SolrRequestHandler
> handler,
> SolrQueryRequest sreq, SolrQueryResponse rsp) {
> sreq.getContext().put( "HttpServletRequest", req );
> super.execute( req, handler, sreq, rsp )
> }
>
> -Hoss
>
>
Re: Access HTTP headers from custom request handler
Posted by Chris Hostetter <ho...@fucit.org>.
: Solr cannot assume that the request would always come from http (think
: of EmbeddedSolrServer) .So it assumes that there are only parameters
exactly.
: Your best bet is to modify SolrDispatchFilter and readthe params and
: set them in the SolrRequest Object
SolrDispatchFilter is designed to be subclassed to make this easy by
overriding the execute method...
protected void execute( HttpServletRequest req, SolrRequestHandler handler,
SolrQueryRequest sreq, SolrQueryResponse rsp) {
sreq.getContext().put( "HttpServletRequest", req );
super.execute( req, handler, sreq, rsp )
}
-Hoss
Re: Access HTTP headers from custom request handler
Posted by Noble Paul നോബിള് नोब्ळ् <no...@gmail.com>.
well unfortunately , no.
Solr cannot assume that the request would always come from http (think
of EmbeddedSolrServer) .So it assumes that there are only parameters
Your best bet is to modify SolrDispatchFilter and readthe params and
set them in the SolrRequest Object
or you can just write a Filter before SolrDispatchFIlter and set the
current httrequest object into a threadlocal
On Thu, Apr 9, 2009 at 6:27 PM, Giovanni De Stefano
<gi...@gmail.com> wrote:
> Hello all,
>
> we are writing a custom request handler and we need to implement some
> business logic according to some HTTP headers.
>
> I see there is no easy way to access HTTP headers from the request handler.
>
> Moreover it seems to me that the HTTPServletness is lost way before the
> custom request handler comes in the game.
>
> Is there any way to access HTTP headers from within the request handler?
>
> Thanks,
> Giovanni
>
--
--Noble Paul