[ 
https://issues.apache.org/jira/browse/SOLR-5532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13840468#comment-13840468
 ] 

Jakob Furrer commented on SOLR-5532:
------------------------------------

Thanks for looking into this issue so fast.
And my apologies for being very sloppy in the bug description.
Due to time constraints, I did not test the code provided above in a standalone 
setting.
I am aware that this is a big no-no. Mea culpa.

I only now figured out that setting the XMLResponseParser triggers the Exception
{code}
solrServer.setParser(new XMLResponseParser());
{code}
Setting the BinaryRequestWriter or not does not influence the result for me.

Side-Question:
The XMLResponseParser is set in my custom application since very long. I cannot 
recall when or why set that specific parser.
Could anyone give my some information whether, when or why this parser should 
(not) be set?

As for
{quote}
A global search for "charset=UTF-8" on the source code of solrj indicates that 
other functions besides "ping" might be affected as well, because there are 
several places where "application/xml; charset=UTF-8" is spelled without a 
space after the semicolon.
{quote}
I am not familiar with the Solr sourcecode at all. I saw these search results, 
where "; charset=utf-8" appears 62 times and ";charset=utf-8" appears 12 times.
>From that I conclude that there is an inconsistency how to spell this encoding 
>type within this library.
{code}
Suchen nach: charset=UTF-8
lucene\common-build.xml(2241): html.append('<meta http-equiv="Content-Type" 
content="text/html; charset=UTF-8">\n')
lucene\analysis\common\src\java\org\apache\lucene\analysis\cjk\package.html(20):
 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
lucene\analysis\common\src\java\org\apache\lucene\analysis\cn\package.html(20): 
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
lucene\analysis\common\src\test\org\apache\lucene\analysis\charfilter\htmlStripReaderTest.html(4):
 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
lucene\analysis\common\src\test\org\apache\lucene\analysis\core\LuceneResourcesWikiPage.html(4):
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
lucene\analysis\icu\src\java\overview.html(19): <META http-equiv="Content-Type" 
content="text/html; charset=UTF-8">
lucene\analysis\morfologik\src\java\overview.html(20): <meta 
http-equiv="Content-Type" content="text/html;charset=UTF-8" />
lucene\analysis\morfologik\src\java\org\apache\lucene\analysis\morfologik\package.html(20):
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
lucene\analysis\smartcn\src\java\org\apache\lucene\analysis\cn\smart\package.html(20):
 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
lucene\analysis\smartcn\src\java\org\apache\lucene\analysis\cn\smart\hhmm\package.html(19):
 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
lucene\analysis\stempel\src\java\overview.html(20): <meta content="text/html; 
charset=UTF-8" http-equiv="content-type">
lucene\benchmark\src\test\org\apache\lucene\benchmark\byTask\feeds\TestHtmlParser.java(76):
 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />" +
lucene\benchmark\src\test\org\apache\lucene\benchmark\byTask\feeds\TestHtmlParser.java(84):
 assertEquals("text/html;charset=UTF-8", tags.get("content-type"));
lucene\demo\src\java\overview.html(19): <meta http-equiv="Content-Type" 
content="text/html; charset=utf-8">
lucene\queryparser\docs\xml\LuceneContribQuery.dtd.entities.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\queryparser\docs\xml\LuceneContribQuery.dtd.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\queryparser\docs\xml\LuceneContribQuery.dtd.org.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\queryparser\docs\xml\LuceneCoreQuery.dtd.entities.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\queryparser\docs\xml\LuceneCoreQuery.dtd.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\queryparser\docs\xml\LuceneCoreQuery.dtd.org.html(3): <meta 
http-equiv='CONTENT-TYPE' content='text/html; charset=UTF-8' />
lucene\site\changes\changes2html.pl(258): <META http-equiv="Content-Type" 
content="text/html; charset=UTF-8"/>
solr\CHANGES.txt(7359): have a valid contentType: curl -H 
'Content-type:text/xml; charset=utf-8' 
solr\CHANGES.txt(7451): content.  Using the contentType: "text/xml; 
charset=utf-8" will force
solr\contrib\clustering\src\test-files\clustering\solr\collection1\conf\solrconfig.xml(421):
 the body. For example, curl now requires: -H 'Content-type:text/xml; 
charset=utf-8'
solr\contrib\dataimporthandler\src\test-files\dih\solr\collection1\conf\contentstream-solrconfig.xml(296):
 the body. For example, curl now requires: -H 'Content-type:text/xml; 
charset=utf-8'
solr\contrib\dataimporthandler\src\test-files\dih\solr\collection1\conf\dataimport-nodatasource-solrconfig.xml(294):
 the body. For example, curl now requires: -H 'Content-type:text/xml; 
charset=utf-8'
solr\contrib\dataimporthandler\src\test-files\dih\solr\collection1\conf\dataimport-solrconfig.xml(295):
 the body. For example, curl now requires: -H 'Content-type:text/xml; 
charset=utf-8'
solr\contrib\dataimporthandler-extras\src\test-files\dihextras\solr\collection1\conf\dataimport-solrconfig.xml(292):
 the body. For example, curl now requires: -H 'Content-type:text/xml; 
charset=utf-8'
solr\contrib\uima\src\test-files\uima\uima-tokenizers-solrconfig.xml(639): now 
requires: -H 'Content-type:text/xml; charset=utf-8' The response
solr\contrib\uima\src\test-files\uima\solr\collection1\conf\solrconfig.xml(640):
 now requires: -H 'Content-type:text/xml; charset=utf-8' The response
solr\contrib\velocity\src\java\org\apache\solr\response\VelocityResponseWriter.java(174):
 return request.getParams().get("v.contentType", "text/html;charset=UTF-8");
solr\core\src\java\org\apache\solr\response\JSONResponseWriter.java(44): static 
String CONTENT_TYPE_JSON_UTF8 = "application/json; charset=UTF-8";
solr\core\src\java\org\apache\solr\response\PHPResponseWriter.java(27): static 
String CONTENT_TYPE_PHP_UTF8="text/x-php;charset=UTF-8";
solr\core\src\java\org\apache\solr\response\PHPSerializedResponseWriter.java(42):
 static String CONTENT_TYPE_PHP_UTF8="text/x-php-serialized;charset=UTF-8";
solr\core\src\java\org\apache\solr\response\QueryResponseWriter.java(46): 
public static String CONTENT_TYPE_XML_UTF8="application/xml; charset=UTF-8";
solr\core\src\java\org\apache\solr\response\QueryResponseWriter.java(47): 
public static String CONTENT_TYPE_TEXT_UTF8="text/plain; charset=UTF-8";
solr\core\src\java\org\apache\solr\response\RubyResponseWriter.java(26): static 
String CONTENT_TYPE_RUBY_UTF8="text/x-ruby;charset=UTF-8";
solr\core\src\java\org\apache\solr\servlet\SolrRequestParsers.java(638): if( 
idx > 0 ) { // remove the charset definition "; charset=utf-8"
solr\core\src\test\org\apache\solr\analysis\htmlStripReaderTest.html(4): <META 
http-equiv="Content-Type" content="text/html; charset=UTF-8">
solr\core\src\test\org\apache\solr\servlet\SolrRequestParserTest.java(216): 
"application/x-www-form-urlencoded; charset=utf-8",
solr\core\src\test-files\solr\collection1\conf\solrconfig-implicitproperties.xml(77):
 <str name="content-type">text/plain; charset=UTF-8</str>
solr\docs\changes\Changes.html(31): <META http-equiv="Content-Type" 
content="text/html; charset=UTF-8"/>
solr\docs\changes\Changes.html(7435): have a valid contentType: curl -H 
'Content-type:text/xml; charset=utf-8'
solr\docs\changes\Changes.html(7527): content.  Using the contentType: 
"text/xml; charset=utf-8" will force
solr\example\example-DIH\solr\db\conf\solrconfig.xml(407): the body. For 
example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-DIH\solr\db\conf\xslt\example.xsl(27): <xsl:output 
media-type="text/html; charset=UTF-8" encoding="UTF-8"/> 
solr\example\example-DIH\solr\db\conf\xslt\luke.xsl(38): <meta 
http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
solr\example\example-DIH\solr\mail\conf\solrconfig.xml(565): the body. For 
example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-DIH\solr\rss\conf\solrconfig.xml(406): the body. For 
example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-DIH\solr\solr\conf\solrconfig.xml(405): the body. For 
example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-DIH\solr\tika\conf\solrconfig.xml(326): the body. For 
example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-schemaless\solr\collection1\conf\solrconfig.xml(999): 
requires: -H 'Content-type:text/xml; charset=utf-8'
solr\example\example-schemaless\solr\collection1\conf\solrconfig.xml(1710): 
<str name="content-type">text/plain; charset=UTF-8</str>
solr\example\exampledocs\test_utf8.sh(41): curl $URL/select --data-binary 
'q=h%C3%A9llo&echoParams=explicit&wt=python' -H 
'Content-type:application/x-www-form-urlencoded; charset=UTF-8' 2> /dev/null | 
grep 'h\\u00e9llo' > /dev/null 2>&1
solr\example\exampledocs\test_utf8.sh(71): curl $URL/select --data-binary 
"q=$URL_UTF8&echoParams=explicit&wt=python"  -H 
'Content-type:application/x-www-form-urlencoded; charset=UTF-8' 2> /dev/null | 
grep $EXPECTED > /dev/null 2>&1
solr\example\solr\collection1\conf\solrconfig.xml(1006): requires: -H 
'Content-type:text/xml; charset=utf-8'
solr\example\solr\collection1\conf\solrconfig.xml(1751): <str 
name="content-type">text/plain; charset=UTF-8</str>
solr\example\solr\collection1\conf\velocity\head.vm(7): <meta 
http-equiv="content-type" content="text/html; charset=UTF-8"/>
solr\scripts\abc(95): rs=`curl ${curl_url} -s -H 'Content-type:text/xml; 
charset=utf-8' -d "<commit/>"`
solr\scripts\abo(94): rs=`curl ${curl_url} -s -H 'Content-type:text/xml; 
charset=utf-8' -d "<optimize/>"`
solr\scripts\commit(87): rs=`curl ${curl_url} -s -H 'Content-type:text/xml; 
charset=utf-8' -d "<commit/>"`
solr\scripts\optimize(87): rs=`curl ${curl_url} -s -H 'Content-type:text/xml; 
charset=utf-8' -d "<optimize/>"`
solr\site\html\tutorial.html(20): <META http-equiv="Content-Type" 
content="text/html; charset=UTF-8" />
solr\solrj\src\java\org\apache\solr\client\solrj\impl\HttpSolrServer.java(273): 
"application/x-www-form-urlencoded; charset=UTF-8");
solr\solrj\src\java\org\apache\solr\client\solrj\impl\XMLResponseParser.java(50):
 public static final String XML_CONTENT_TYPE = "application/xml; charset=UTF-8";
solr\solrj\src\java\org\apache\solr\client\solrj\util\ClientUtils.java(54): 
public static final String TEXT_XML = "application/xml; charset=UTF-8";  
solr\solrj\src\test\org\apache\solr\client\solrj\impl\BasicHttpSolrServerTest.java(253):
 assertEquals("application/x-www-form-urlencoded; charset=UTF-8", 
DebugServlet.headers.get("Content-Type"));
solr\solrj\src\test\org\apache\solr\client\solrj\impl\BasicHttpSolrServerTest.java(289):
 assertEquals("application/x-www-form-urlencoded; charset=UTF-8", 
DebugServlet.headers.get("Content-Type"));
solr\solrj\src\test\org\apache\solr\client\solrj\impl\BasicHttpSolrServerTest.java(358):
 assertEquals("application/xml; charset=UTF-8", 
DebugServlet.headers.get("Content-Type"));
solr\solrj\src\test\org\apache\solr\client\solrj\impl\BasicHttpSolrServerTest.java(374):
 assertEquals("application/xml; charset=UTF-8", 
DebugServlet.headers.get("Content-Type"));
solr\test-framework\src\java\org\apache\solr\util\RestTestHarness.java(149): 
connection.setRequestProperty("Content-Type", "application/json; 
charset=utf-8");
solr\webapp\web\js\scripts\dashboard.js(57): core_basepath + 
'/admin/file/?file=admin-extra.menu-top.html&contentType=text/html;charset=utf-8',
solr\webapp\web\js\scripts\dashboard.js(67): core_basepath + 
'/admin/file/?file=admin-extra.menu-bottom.html&contentType=text/html;charset=utf-8',
solr\webapp\web\js\scripts\file.js(29): + '&contentType=text/xml;charset=utf-8';
Es wurden 74 Vorkommen in 62 Datei(en) gefunden.
{code}

> HttpSolrServer does not accept content type of "ping" response
> --------------------------------------------------------------
>
>                 Key: SOLR-5532
>                 URL: https://issues.apache.org/jira/browse/SOLR-5532
>             Project: Solr
>          Issue Type: New Feature
>    Affects Versions: 4.6
>         Environment: Windows 7, Java 1.7.0_45 (64bit), solr-solrj-4.6.0.jar
>            Reporter: Jakob Furrer
>
> I just upgraded my Solr instance and with it I also upgraded the solrj 
> library in our custom application which sends diverse requests and queries to 
> Solr.
> I use the "ping" method to determine whether Solr started correctly under the 
> configured address. Since the upgrade the ping response results in an error:
> {code:xml}
> Cause: org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: 
> Expected content type application/xml; charset=UTF-8 but got 
> application/xml;charset=UTF-8.
> <?xml version="1.0" encoding="UTF-8"?>
> <response>
> <lst name="responseHeader"><int name="status">0</int><int 
> name="QTime">0</int><lst name="params"><str name="df">searchtext</str><str 
> name="echoParams">all</str><str name="rows">10</str><str 
> name="echoParams">all</str><str name="wt">xml</str><str 
> name="version">2.2</str><str name="q">solrpingquery</str><str 
> name="distrib">false</str></lst></lst><str name="status">OK</str>
> </response>
> {code}
> The Solr application itself works fine.
> Using an older version of the solrj library than solr-solrj-4.6.0.jar (e.g. 
> solr-solrj-4.5.1.jar) in the custom application does not produce this error.
> The Exception is produced in a Code block (_HttpSolrServer.java_, method 
> _request(...)_, around. line 140) which has been introduced with version 
> 4.6.0.
> Code to reproduce the error:
> {code:xml}
> try {
>   HttpSolrServer solrServer = new 
> HttpSolrServer("my-solr-application-address");
>   solrServer.ping();
>   } catch (Exception e) {
>     e.printStackTrace();
>   }
> }
> {code}
> A global search for "charset=UTF-8" on the source code of solrj indicates 
> that other functions besides "ping" might be affected as well, because there 
> are several places where "application/xml; charset=UTF-8" is spelled without 
> a space after the semicolon.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to