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 Antonio Eggberg <an...@yahoo.se> on 2007/01/31 09:21:23 UTC

Couple of ruby/solrb questions..

Hi: 

Two questions ..

I am wondering about the following in the file solrb/lib/solr/connection.rb we are doing http post 
{ "Content-Type" => "application/x-www-form-urlencoded; charset=utf-8" })
however the file under example/exampledocs/post.sh is using 
Content-type:text/xml; charset=utf-8
I would like to know why? to my understanding application/x-www is under FORM submission.. no?

In the file solrb/lib/solr/request/select.rb we are using ERB::Util  in line ..

if value.respond_to? :each
        value.each { |v| http_params << "#{key}=#ERB::Util::url_encode(v)}" unless v.nil?}
      else
        http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?



Shouldn't the above needs to html_escape ?? no ?? Could you please explain.

I appreciate the clarification.. 

Regards

 		
---------------------------------

Stava rätt! Stava lätt! Yahoo! Mails stavkontroll tar hand om tryckfelen och mycket mer! Få den på http://se.mail.yahoo.com

Re: Couple of ruby/solrb questions..

Posted by Chris Hostetter <ho...@fucit.org>.
: This feels like a bug, is it ticketed? Solr::Request::Select requests
: are POSTing URL encoded name/value pairs so the Content-type is
: appropriate...But Solr::Request::AddDocument (and others) are posting
: xml so the Content-type should be text/xml. There needs to be logic
: for differentiating between the two.

At the moment, when POSTing xml docs to /update the SolrUpdateServlet
ignores the content-type -- but it would definitely be wise to fix this in
solrb since the recently commited alternate way of doing updates
(which allows for plugable UpdateRequestHandlers so we can start
supporting alternate formats for updates) requires that the content-type
be set appropriately: application/x-www-form-urlencoded for simple key=val
pairs, multipart/* for file upload style updates, and anything else for
"raw posting" of data.


-Hoss


Re: Couple of ruby/solrb questions..

Posted by Edward Summers <eh...@pobox.com>.
On Jan 31, 2007, at 3:21 AM, Antonio Eggberg wrote:

> Hi:
>
> Two questions ..
>
> I am wondering about the following in the file solrb/lib/solr/ 
> connection.rb we are doing http post
> { "Content-Type" => "application/x-www-form-urlencoded;  
> charset=utf-8" })
> however the file under example/exampledocs/post.sh is using
> Content-type:text/xml; charset=utf-8
> I would like to know why? to my understanding application/x-www is  
> under FORM submission.. no?

This feels like a bug, is it ticketed? Solr::Request::Select requests  
are POSTing URL encoded name/value pairs so the Content-type is  
appropriate...But Solr::Request::AddDocument (and others) are posting  
xml so the Content-type should be text/xml. There needs to be logic  
for differentiating between the two.

> In the file solrb/lib/solr/request/select.rb we are using  
> ERB::Util  in line ..
>
> if value.respond_to? :each
>         value.each { |v| http_params << "#{key} 
> =#ERB::Util::url_encode(v)}" unless v.nil?}
>       else
>         http_params << "#{key}=#{ERB::Util::url_encode(value)}"  
> unless value.nil?
>
>
> Shouldn't the above needs to html_escape ?? no ?? Could you please  
> explain.

In this case the values need to be URL encoded because of the Content- 
Type for posting a select request. So I don't see a problem here.

//Ed