[HtmlUnit] SVN: [14745] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ util/EncodingSniffer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14745] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ util/EncodingSniffer.java

HtmlUnit - Dev mailing list
Revision: 14745
          http://sourceforge.net/p/htmlunit/code/14745
Author:   rbri
Date:     2017-07-31 15:53:36 +0000 (Mon, 31 Jul 2017)
Log Message:
-----------
simplify

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/EncodingSniffer.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/EncodingSniffer.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/EncodingSniffer.java 2017-07-30 14:20:35 UTC (rev 14744)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/EncodingSniffer.java 2017-07-31 15:53:36 UTC (rev 14745)
@@ -615,21 +615,19 @@
      *         could not be determined
      */
     public static Charset sniffEncodingFromHttpHeaders(final List<NameValuePair> headers) {
-        Charset encoding = null;
         for (final NameValuePair pair : headers) {
             final String name = pair.getName();
             if ("content-type".equalsIgnoreCase(name)) {
-                final String value = pair.getValue();
-                encoding = extractEncodingFromContentType(value);
+                final Charset encoding = extractEncodingFromContentType(pair.getValue());
                 if (encoding != null) {
-                    break;
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Encoding found in HTTP headers: '" + encoding + "'.");
+                    }
+                    return encoding;
                 }
             }
         }
-        if (encoding != null && LOG.isDebugEnabled()) {
-            LOG.debug("Encoding found in HTTP headers: '" + encoding + "'.");
-        }
-        return encoding;
+        return null;
     }
 
     /**


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop