You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2007/05/05 12:14:02 UTC

POST parameter handling change?

This works fine on an older (trunk at some point a month or two ago)  
version of Solr (in Ruby code):

   Net::HTTP.new('localhost',8888).post("/solr/select",  
"wt=ruby&q=rossetti", { "Content-Type" => "application/x-www-form- 
urlencoded; charset=utf-8" }).body

But on trunk I get an error that the q parameter is missing.  POST  
parameters are being ignored.

Help!  What happened?   I'm going to go back and review the changes  
that have been made lately, and maybe there is something I need to  
change in the config?

Thanks,
	Erik


Re: POST parameter handling change?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 5, 2007, at 12:36 PM, Ryan McKinley wrote:

> Erik Hatcher wrote:
>> On May 5, 2007, at 6:14 AM, Erik Hatcher wrote:
>>> This works fine on an older (trunk at some point a month or two  
>>> ago) version of Solr (in Ruby code):
>>>
>>>   Net::HTTP.new('localhost',8888).post("/solr/select",  
>>> "wt=ruby&q=rossetti", { "Content-Type" => "application/x-www-form- 
>>> urlencoded; charset=utf-8" }).body
>>>
>>> But on trunk I get an error that the q parameter is missing.   
>>> POST parameters are being ignored.
>>>
>>> Help!  What happened?   I'm going to go back and review the  
>>> changes that have been made lately, and maybe there is something  
>>> I need to change in the config?
>> Ok, I changed to handleSelect="false" in solrconfig:
>>     <requestDispatcher handleSelect="false">
>> And it now works.  But I'm confused about the handleSelect  
>> switch.  I'm staring at the code where it's used in  
>> SolrDispatchFilter now and don't understand what's going on yet or  
>> why we need this switch.
>> Ryan?
>
> Currently the RequestDispatcher and SolrServlet can take care of "/ 
> select" -- the RequestDispatcher has slightly different ways to  
> parse requests and spits out errors slightly different then  
> SolrServlet.
>
> the handleSelect="false" lets you choose what behavior you want  
> from solrconfig.xml
>
> ----------
>
> All that said, you found a bug!
>
> [line 370] SolrRequestParsers.parseParamsAndFillStreams() looks at  
> the request and figures out how to parse it.
>
> I gets the content type and compares it to "application/x-www-form- 
> urlencoded"
>
> Since your content includes the charset, it dose not match where it  
> should.
>
> I'll post a change shortly.

Fixed!   Thanks for that quick turn-around, including the nicely test  
driven repair you made.

It took me a while to spot this, because I'm not svn up'ing  
everywhere all the time.  This is where having solr-ruby under  
continuous integration would have helped, it would have sensed the  
regression because I changed to the Luke request handler (to get rid  
of IndexInfoRequestHandler) with wt=ruby as a POST.  Here's the way  
it's wrapped in solr-ruby:

   ruby -I lib -r solr  -e 'p Solr::Connection.new("http://localhost: 
8888/solr").info.num_docs'

(-I/-r are equivalent to Java's classpath and import statements)

Thanks again Ryan.

	Erik


Re: POST parameter handling change?

Posted by Ryan McKinley <ry...@gmail.com>.
Erik Hatcher wrote:
> 
> On May 5, 2007, at 6:14 AM, Erik Hatcher wrote:
>> This works fine on an older (trunk at some point a month or two ago) 
>> version of Solr (in Ruby code):
>>
>>   Net::HTTP.new('localhost',8888).post("/solr/select", 
>> "wt=ruby&q=rossetti", { "Content-Type" => 
>> "application/x-www-form-urlencoded; charset=utf-8" }).body
>>
>> But on trunk I get an error that the q parameter is missing.  POST 
>> parameters are being ignored.
>>
>> Help!  What happened?   I'm going to go back and review the changes 
>> that have been made lately, and maybe there is something I need to 
>> change in the config?
> 
> Ok, I changed to handleSelect="false" in solrconfig:
> 
>     <requestDispatcher handleSelect="false">
> 
> And it now works.  But I'm confused about the handleSelect switch.  I'm 
> staring at the code where it's used in SolrDispatchFilter now and don't 
> understand what's going on yet or why we need this switch.
> 
> Ryan?
> 

Currently the RequestDispatcher and SolrServlet can take care of 
"/select" -- the RequestDispatcher has slightly different ways to parse 
requests and spits out errors slightly different then SolrServlet.

the handleSelect="false" lets you choose what behavior you want from 
solrconfig.xml

----------

All that said, you found a bug!

[line 370] SolrRequestParsers.parseParamsAndFillStreams() looks at the 
request and figures out how to parse it.

I gets the content type and compares it to 
"application/x-www-form-urlencoded"

Since your content includes the charset, it dose not match where it should.

I'll post a change shortly.

ryan



Re: POST parameter handling change?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 5, 2007, at 6:14 AM, Erik Hatcher wrote:
> This works fine on an older (trunk at some point a month or two  
> ago) version of Solr (in Ruby code):
>
>   Net::HTTP.new('localhost',8888).post("/solr/select",  
> "wt=ruby&q=rossetti", { "Content-Type" => "application/x-www-form- 
> urlencoded; charset=utf-8" }).body
>
> But on trunk I get an error that the q parameter is missing.  POST  
> parameters are being ignored.
>
> Help!  What happened?   I'm going to go back and review the changes  
> that have been made lately, and maybe there is something I need to  
> change in the config?

Ok, I changed to handleSelect="false" in solrconfig:

	<requestDispatcher handleSelect="false">

And it now works.  But I'm confused about the handleSelect switch.   
I'm staring at the code where it's used in SolrDispatchFilter now and  
don't understand what's going on yet or why we need this switch.

Ryan?

	Erik