From c7a3b968937a2219bae7b6f83a5f2c85d08f15d7 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Fri, 6 Dec 2013 19:01:03 +0000 Subject: [PATCH] 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 --- solr/CHANGES.txt | 8 ++++++-- .../apache/solr/client/solrj/impl/HttpSolrServer.java | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index d51fcb0df65..3ae9bcb31e3 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 ---------------------- diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java index ff4a5aa429a..11b680ff4c3 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java @@ -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) {