SOLR-5532: SolrJ Content-Type validation is too strict for some webcontainers / proxies.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1548659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-12-06 19:01:03 +00:00
parent d8f1161418
commit c7a3b96893
2 changed files with 13 additions and 5 deletions

View File

@ -192,8 +192,12 @@ Bug Fixes
* SOLR-5524: Exception when using Query Function inside Scale Function.
(Trey Grainger, yonik)
* SOLR-5540: HdfsLockFactory should explicitly create the lock parent directory if
necessary. (Mark Miller)
* SOLR-5540: HdfsLockFactory should explicitly create the lock parent directory
if necessary. (Mark Miller)
* SOLR-5532: SolrJ Content-Type validation is too strict for some
webcontainers / proxies. (Jakob Furrer, hossman, Shawn Heisey, Uwe Schindler,
Mark Miller)
Optimizations
----------------------

View File

@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.apache.commons.io.IOUtils;
@ -41,6 +42,7 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.mime.FormBodyPart;
import org.apache.http.entity.mime.HttpMultipartMode;
@ -437,9 +439,11 @@ public class HttpSolrServer extends SolrServer {
String procCt = processor.getContentType();
if (procCt != null) {
if (!contentType.equals(procCt)) {
// unexpected content type
String msg = "Expected content type " + procCt + " but got " + contentType + ".";
String procMimeType = ContentType.parse(procCt).getMimeType().trim().toLowerCase(Locale.ROOT);
String mimeType = ContentType.parse(contentType).getMimeType().trim().toLowerCase(Locale.ROOT);
if (!procMimeType.equals(mimeType)) {
// unexpected mime type
String msg = "Expected mime type " + procMimeType + " but got " + mimeType + ".";
Header encodingHeader = response.getEntity().getContentEncoding();
String encoding;
if (encodingHeader != null) {