HoustonPutman commented on a change in pull request #1480:
URL: https://github.com/apache/lucene-solr/pull/1480#discussion_r421078522
##########
File path:
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
##########
@@ -568,12 +568,18 @@ private HttpEntityEnclosingRequestBase
fillContentStream(SolrRequest request, Co
// Read the contents
entity = response.getEntity();
respBody = entity.getContent();
- Header ctHeader = response.getLastHeader("content-type");
- String contentType;
- if (ctHeader != null) {
- contentType = ctHeader.getValue();
- } else {
- contentType = "";
+ String mimeType = null;
+ Charset charset = null;
+ String charsetName = null;
+
+ ContentType contentType = ContentType.get(entity);
+ if (contentType != null) {
+ mimeType = contentType.getMimeType().trim().toLowerCase(Locale.ROOT);
+ charset = contentType.getCharset();
+
+ if (charset != null) {
+ charsetName = charset.name();
+ }
}
Review comment:
I would recommend setting charset to FALLBACK_CHARSET if it's null here,
and setting the charsetName afterwards. You have potential for some
nullPointerExceptions below. such as on lines 626 and 634
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]