1 /* |
1 /* |
2 * reserved comment block |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT REMOVE OR ALTER! |
3 * @LastModified: Oct 2017 |
4 */ |
4 */ |
5 /* |
5 /* |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
8 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.xerces.internal.xinclude; |
22 package com.sun.org.apache.xerces.internal.xinclude; |
23 |
23 |
|
24 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager; |
|
25 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; |
|
26 import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; |
|
27 import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; |
|
28 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; |
|
29 import com.sun.org.apache.xerces.internal.util.EncodingMap; |
|
30 import com.sun.org.apache.xerces.internal.util.HTTPInputSource; |
|
31 import com.sun.org.apache.xerces.internal.util.MessageFormatter; |
|
32 import com.sun.org.apache.xerces.internal.util.XMLChar; |
|
33 import com.sun.org.apache.xerces.internal.xni.XMLString; |
|
34 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; |
24 import java.io.BufferedInputStream; |
35 import java.io.BufferedInputStream; |
25 import java.io.IOException; |
36 import java.io.IOException; |
26 import java.io.InputStream; |
37 import java.io.InputStream; |
27 import java.io.InputStreamReader; |
38 import java.io.InputStreamReader; |
28 import java.io.Reader; |
39 import java.io.Reader; |
30 import java.net.URL; |
41 import java.net.URL; |
31 import java.net.URLConnection; |
42 import java.net.URLConnection; |
32 import java.util.Iterator; |
43 import java.util.Iterator; |
33 import java.util.Locale; |
44 import java.util.Locale; |
34 import java.util.Map; |
45 import java.util.Map; |
35 |
|
36 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager; |
|
37 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; |
|
38 import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; |
|
39 import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; |
|
40 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; |
|
41 import com.sun.org.apache.xerces.internal.util.EncodingMap; |
|
42 import com.sun.org.apache.xerces.internal.util.HTTPInputSource; |
|
43 import com.sun.org.apache.xerces.internal.util.MessageFormatter; |
|
44 import com.sun.org.apache.xerces.internal.util.XMLChar; |
|
45 import com.sun.org.apache.xerces.internal.xni.XMLString; |
|
46 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; |
|
47 |
46 |
48 /** |
47 /** |
49 * This class is used for reading resources requested in <include> elements, |
48 * This class is used for reading resources requested in <include> elements, |
50 * when the parse attribute of the <include> element is "text". Using this |
49 * when the parse attribute of the <include> element is "text". Using this |
51 * class will open the location, detect the encoding, and discard the byte order |
50 * class will open the location, detect the encoding, and discard the byte order |
131 if (urlCon instanceof HttpURLConnection && source instanceof HTTPInputSource) { |
130 if (urlCon instanceof HttpURLConnection && source instanceof HTTPInputSource) { |
132 final HttpURLConnection urlConnection = (HttpURLConnection) urlCon; |
131 final HttpURLConnection urlConnection = (HttpURLConnection) urlCon; |
133 final HTTPInputSource httpInputSource = (HTTPInputSource) source; |
132 final HTTPInputSource httpInputSource = (HTTPInputSource) source; |
134 |
133 |
135 // set request properties |
134 // set request properties |
136 Iterator propIter = httpInputSource.getHTTPRequestProperties(); |
135 Iterator<Map.Entry<String, String>> propIter = httpInputSource.getHTTPRequestProperties(); |
137 while (propIter.hasNext()) { |
136 while (propIter.hasNext()) { |
138 Map.Entry entry = (Map.Entry) propIter.next(); |
137 Map.Entry<String, String> entry = propIter.next(); |
139 urlConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue()); |
138 urlConnection.setRequestProperty(entry.getKey(), entry.getValue()); |
140 } |
139 } |
141 |
140 |
142 // set preference for redirection |
141 // set preference for redirection |
143 boolean followRedirects = httpInputSource.getFollowHTTPRedirects(); |
142 boolean followRedirects = httpInputSource.getFollowHTTPRedirects(); |
144 if (!followRedirects) { |
143 if (!followRedirects) { |