Skip to content

Commit 7264eea

Browse files
author
Niall Pemberton
committed
Refactoring - move mine/encoding content type detection into the calculateHttpEncoding() method where its used
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1004514 13f79535-47bb-0310-9956-ffa450edef68
1 parent e4540bb commit 7264eea

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/org/apache/commons/io/input/XmlStreamReader.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,10 @@ private void doHttpStream(InputStream is, String httpContentType,
465465
boolean lenient) throws IOException {
466466
BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
467467
BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
468-
String cTMime = getContentTypeMime(httpContentType);
469-
String cTEnc = getContentTypeEncoding(httpContentType);
470468
String bomEnc = bom.getBOMCharsetName();
471469
String xmlGuessEnc = pis.getBOMCharsetName();
472470
String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
473-
this.encoding = calculateHttpEncoding(cTMime, cTEnc, bomEnc,
471+
this.encoding = calculateHttpEncoding(httpContentType, bomEnc,
474472
xmlGuessEnc, xmlEnc, lenient);
475473
this.reader = new InputStreamReader(is, encoding);
476474
}
@@ -529,8 +527,7 @@ private String calculateRawEncoding(String bomEnc, String xmlGuessEnc,
529527
/**
530528
* Calculate the HTTP encoding.
531529
*
532-
* @param cTMime Mime Content Type
533-
* @param cTEnc the content type encoding
530+
* @param httpContentType The HTTP content type
534531
* @param bomEnc BOM encoding
535532
* @param xmlGuessEnc XML Guess encoding
536533
* @param xmlEnc XML encoding
@@ -539,9 +536,11 @@ private String calculateRawEncoding(String bomEnc, String xmlGuessEnc,
539536
* @return the HTTP encoding
540537
* @throws IOException thrown if there is a problem reading the stream.
541538
*/
542-
private String calculateHttpEncoding(String cTMime, String cTEnc,
539+
private String calculateHttpEncoding(String httpContentType,
543540
String bomEnc, String xmlGuessEnc, String xmlEnc,
544541
boolean lenient) throws IOException {
542+
String cTMime = getContentTypeMime(httpContentType);
543+
String cTEnc = getContentTypeEncoding(httpContentType);
545544
String encoding;
546545
if (lenient & xmlEnc != null) {
547546
encoding = xmlEnc;

0 commit comments

Comments
 (0)