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 Thorsten Scherler <th...@apache.org> on 2007/02/03 18:14:34 UTC

Connecting custom RequestHandler

Hi all,

I am working on SOLR-133 and I have wrapped up a first version of the
XmlUpdateRequestHandlerStax.java. Now I am trying to connect it in the
example but I have some problems.

I am trying:
<requestHandler name="/update/stax"
class="solr.XmlUpdateRequestHandlerStax" />

Trying to curl to URL=http://localhost:8983/solr/update/stax
I get:
Posting file solr.xml to http://localhost:8983/solr/update/stax
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int
name="QTime">67</int></lst>
</response>

<html>
<head>
<title>Error 400 missing content stream stax</title>
</head>
<body>
<h2>HTTP ERROR: 400</h2><pre>missing content stream stax</pre>
<p>RequestURI=/solr/update/stax</p>
...

What did I forget that the content stream is not passed to the method?

Any tip, hint or shoot in the dark welcome.


salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java & XML                consulting, training and solutions


Re: Connecting custom RequestHandler

Posted by Thorsten Scherler <th...@apache.org>.
On Sat, 2007-02-03 at 18:41 -0800, Ryan McKinley wrote:
> The 'new' request parser reads the content type header to see if it
> should parse the body as params or not.  If the content type is
> "application/x-www-form-urlencoded" it parses them as params, if it is
> "multipart/*" it parses them as multipart.  if it is *anything* else,
> it reads the body as a stream.
> 
> curl defaults the content type to "application/x-www-form-urlencoded"
> 
> so you will need to run curl with  -H "Content-Type: text/xml
> 
> - - - - - - -


Hmm, I patched the post.sh only regarding the URL.

FILES=$*
URL=http://localhost:8983/solr/update/stax

for f in $FILES; do
  echo Posting file $f to $URL
  curl $URL --data-binary @$f -H 'Content-type:text/xml; charset=utf-8' 
  echo
done

Meaning what you describe is already in there. 

I now played around again with it and surprise it works now. 

Thanks Ryan.

> 
> I should add this to the wiki.
> 
> Can we change the post.sh to use  -H "Content-Type: text/xml"?  This
> will not affect old updater and will work for new UpdateHandlers.

It is see above. Not sure why it did not work the yesterday.

Thanks for the feedback.

salu2

> ryan
> 
> 
> On 2/3/07, Thorsten Scherler <th...@apache.org> wrote:
> > On Sat, 2007-02-03 at 18:14 +0100, Thorsten Scherler wrote:
> > > Hi all,
> > >
> > > I am working on SOLR-133 and I have wrapped up a first version of the
> > > XmlUpdateRequestHandlerStax.java. Now I am trying to connect it in the
> > > example but I have some problems.
> > >
> > > I am trying:
> > > <requestHandler name="/update/stax"
> > > class="solr.XmlUpdateRequestHandlerStax" />
> > >
> > > Trying to curl to URL=http://localhost:8983/solr/update/stax
> >
> > Debugging this I used http://localhost:8983/solr/update/xml and I get
> > the same error.
> >
> > So I figured that we still use the SolrUpdateServlet @Deprecated in the
> > post.sh.
> >
> > For now I can test the StAX changing
> > XmlUpdateRequestHandlerStax legacyUpdateHandler;
> > and implementing a doLegacyUpdate method in the handler.
> >
> > salu2
> >
> > > I get:
> > > Posting file solr.xml to http://localhost:8983/solr/update/stax
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <response>
> > > <lst name="responseHeader"><int name="status">0</int><int
> > > name="QTime">67</int></lst>
> > > </response>
> > >
> > > <html>
> > > <head>
> > > <title>Error 400 missing content stream stax</title>
> > > </head>
> > > <body>
> > > <h2>HTTP ERROR: 400</h2><pre>missing content stream stax</pre>
> > > <p>RequestURI=/solr/update/stax</p>
> > > ...
> > >
> > > What did I forget that the content stream is not passed to the method?
> > >
> > > Any tip, hint or shoot in the dark welcome.
> > >
> > >
> > > salu2
> > --
> > Thorsten Scherler                                 thorsten.at.apache.org
> > Open Source Java & XML                consulting, training and solutions
> >
> >
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java & XML                consulting, training and solutions


Re: Connecting custom RequestHandler

Posted by Ryan McKinley <ry...@gmail.com>.
The 'new' request parser reads the content type header to see if it
should parse the body as params or not.  If the content type is
"application/x-www-form-urlencoded" it parses them as params, if it is
"multipart/*" it parses them as multipart.  if it is *anything* else,
it reads the body as a stream.

curl defaults the content type to "application/x-www-form-urlencoded"

so you will need to run curl with  -H "Content-Type: text/xml

- - - - - - -

I should add this to the wiki.

Can we change the post.sh to use  -H "Content-Type: text/xml"?  This
will not affect old updater and will work for new UpdateHandlers.

ryan


On 2/3/07, Thorsten Scherler <th...@apache.org> wrote:
> On Sat, 2007-02-03 at 18:14 +0100, Thorsten Scherler wrote:
> > Hi all,
> >
> > I am working on SOLR-133 and I have wrapped up a first version of the
> > XmlUpdateRequestHandlerStax.java. Now I am trying to connect it in the
> > example but I have some problems.
> >
> > I am trying:
> > <requestHandler name="/update/stax"
> > class="solr.XmlUpdateRequestHandlerStax" />
> >
> > Trying to curl to URL=http://localhost:8983/solr/update/stax
>
> Debugging this I used http://localhost:8983/solr/update/xml and I get
> the same error.
>
> So I figured that we still use the SolrUpdateServlet @Deprecated in the
> post.sh.
>
> For now I can test the StAX changing
> XmlUpdateRequestHandlerStax legacyUpdateHandler;
> and implementing a doLegacyUpdate method in the handler.
>
> salu2
>
> > I get:
> > Posting file solr.xml to http://localhost:8983/solr/update/stax
> > <?xml version="1.0" encoding="UTF-8"?>
> > <response>
> > <lst name="responseHeader"><int name="status">0</int><int
> > name="QTime">67</int></lst>
> > </response>
> >
> > <html>
> > <head>
> > <title>Error 400 missing content stream stax</title>
> > </head>
> > <body>
> > <h2>HTTP ERROR: 400</h2><pre>missing content stream stax</pre>
> > <p>RequestURI=/solr/update/stax</p>
> > ...
> >
> > What did I forget that the content stream is not passed to the method?
> >
> > Any tip, hint or shoot in the dark welcome.
> >
> >
> > salu2
> --
> Thorsten Scherler                                 thorsten.at.apache.org
> Open Source Java & XML                consulting, training and solutions
>
>

Re: Connecting custom RequestHandler

Posted by Thorsten Scherler <th...@apache.org>.
On Sat, 2007-02-03 at 18:14 +0100, Thorsten Scherler wrote:
> Hi all,
> 
> I am working on SOLR-133 and I have wrapped up a first version of the
> XmlUpdateRequestHandlerStax.java. Now I am trying to connect it in the
> example but I have some problems.
> 
> I am trying:
> <requestHandler name="/update/stax"
> class="solr.XmlUpdateRequestHandlerStax" />
> 
> Trying to curl to URL=http://localhost:8983/solr/update/stax

Debugging this I used http://localhost:8983/solr/update/xml and I get
the same error.

So I figured that we still use the SolrUpdateServlet @Deprecated in the
post.sh.

For now I can test the StAX changing 
XmlUpdateRequestHandlerStax legacyUpdateHandler;
and implementing a doLegacyUpdate method in the handler.

salu2

> I get:
> Posting file solr.xml to http://localhost:8983/solr/update/stax
> <?xml version="1.0" encoding="UTF-8"?>
> <response>
> <lst name="responseHeader"><int name="status">0</int><int
> name="QTime">67</int></lst>
> </response>
> 
> <html>
> <head>
> <title>Error 400 missing content stream stax</title>
> </head>
> <body>
> <h2>HTTP ERROR: 400</h2><pre>missing content stream stax</pre>
> <p>RequestURI=/solr/update/stax</p>
> ...
> 
> What did I forget that the content stream is not passed to the method?
> 
> Any tip, hint or shoot in the dark welcome.
> 
> 
> salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java & XML                consulting, training and solutions