https://issues.shibboleth.net/jira/browse/CPPXT-96
[shibboleth/cpp-xmltooling.git] / xmltooling / util / ParserPool.cpp
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * ParserPool.cpp
23  *
24  * A thread-safe pool of parsers that share characteristics.
25  */
26
27 #include "internal.h"
28 #include "exceptions.h"
29 #include "logging.h"
30 #include "util/CurlURLInputStream.h"
31 #include "util/NDC.h"
32 #include "util/PathResolver.h"
33 #include "util/ParserPool.h"
34 #include "util/Threads.h"
35 #include "util/XMLHelper.h"
36
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <algorithm>
40 #include <functional>
41 #include <boost/algorithm/string.hpp>
42 #include <boost/bind.hpp>
43 #include <xercesc/util/PlatformUtils.hpp>
44 #include <xercesc/util/XMLUniDefs.hpp>
45 #include <xercesc/sax/SAXException.hpp>
46 #include <xercesc/framework/MemBufInputSource.hpp>
47 #include <xercesc/framework/LocalFileInputSource.hpp>
48 #include <xercesc/framework/Wrapper4InputSource.hpp>
49
50 using namespace xmltooling::logging;
51 using namespace xmltooling;
52 using namespace xercesc;
53 using namespace boost;
54 using namespace std;
55
56
57 namespace {
58     class MyErrorHandler : public DOMErrorHandler {
59     public:
60         unsigned int errors;
61
62         MyErrorHandler() : errors(0) {}
63
64         bool handleError(const DOMError& e)
65         {
66 #ifdef _DEBUG
67             xmltooling::NDC ndc("handleError");
68 #endif
69             Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool");
70
71             DOMLocator* locator=e.getLocation();
72             auto_ptr_char temp(e.getMessage());
73
74             switch (e.getSeverity()) {
75                 case DOMError::DOM_SEVERITY_WARNING:
76                     log.warnStream() << "warning on line " << locator->getLineNumber()
77                         << ", column " << locator->getColumnNumber()
78                         << ", message: " << temp.get() << logging::eol;
79                     return true;
80
81                 case DOMError::DOM_SEVERITY_ERROR:
82                     ++errors;
83                     log.errorStream() << "error on line " << locator->getLineNumber()
84                         << ", column " << locator->getColumnNumber()
85                         << ", message: " << temp.get() << logging::eol;
86                     return true;
87
88                 case DOMError::DOM_SEVERITY_FATAL_ERROR:
89                     ++errors;
90                     log.errorStream() << "fatal error on line " << locator->getLineNumber()
91                         << ", column " << locator->getColumnNumber()
92                         << ", message: " << temp.get() << logging::eol;
93                     return true;
94             }
95
96             ++errors;
97             log.errorStream() << "undefined error type on line " << locator->getLineNumber()
98                 << ", column " << locator->getColumnNumber()
99                 << ", message: " << temp.get() << logging::eol;
100             return false;
101         }
102     };
103 }
104
105
106 ParserPool::ParserPool(bool namespaceAware, bool schemaAware)
107         : m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()), m_security(new SecurityManager()) {
108
109     int expLimit = 0;
110     const char* env = getenv("XMLTOOLING_ENTITY_EXPANSION_LIMIT");
111     if (env) {
112         expLimit = atoi(env);
113     }
114     if (expLimit <= 0)
115         expLimit = XMLTOOLING_ENTITY_EXPANSION_LIMIT;
116     m_security->setEntityExpansionLimit(expLimit);
117 }
118
119 ParserPool::~ParserPool()
120 {
121     while(!m_pool.empty()) {
122         m_pool.top()->release();
123         m_pool.pop();
124     }
125 }
126
127 DOMDocument* ParserPool::newDocument()
128 {
129     return DOMImplementationRegistry::getDOMImplementation(nullptr)->createDocument();
130 }
131
132 #ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS
133
134 DOMDocument* ParserPool::parse(DOMLSInput& domsrc)
135 {
136     DOMLSParser* parser=checkoutBuilder();
137     XercesJanitor<DOMLSParser> janitor(parser);
138     try {
139         MyErrorHandler deh;
140         parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, dynamic_cast<DOMErrorHandler*>(&deh));
141         DOMDocument* doc=parser->parse(&domsrc);
142         if (deh.errors) {
143             if (doc)
144                 doc->release();
145             throw XMLParserException("XML error(s) during parsing, check log for specifics");
146         }
147         parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr);
148         parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
149         checkinBuilder(janitor.release());
150         return doc;
151     }
152     catch (XMLException& ex) {
153         parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr);
154         parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
155         checkinBuilder(janitor.release());
156         auto_ptr_char temp(ex.getMessage());
157         throw XMLParserException(string("Xerces error during parsing: ") + (temp.get() ? temp.get() : "no message"));
158     }
159     catch (XMLToolingException&) {
160         parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr);
161         parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
162         checkinBuilder(janitor.release());
163         throw;
164     }
165 }
166
167 #else
168
169 DOMDocument* ParserPool::parse(DOMInputSource& domsrc)
170 {
171     DOMBuilder* parser=checkoutBuilder();
172     XercesJanitor<DOMBuilder> janitor(parser);
173     try {
174         MyErrorHandler deh;
175         parser->setErrorHandler(&deh);
176         DOMDocument* doc=parser->parse(domsrc);
177         if (deh.errors) {
178             if (doc)
179                 doc->release();
180             throw XMLParserException("XML error(s) during parsing, check log for specifics");
181         }
182         parser->setErrorHandler(nullptr);
183         parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
184         checkinBuilder(janitor.release());
185         return doc;
186     }
187     catch (XMLException& ex) {
188         parser->setErrorHandler(nullptr);
189         parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
190         checkinBuilder(janitor.release());
191         auto_ptr_char temp(ex.getMessage());
192         throw XMLParserException(string("Xerces error during parsing: ") + (temp.get() ? temp.get() : "no message"));
193     }
194     catch (XMLToolingException&) {
195         parser->setErrorHandler(nullptr);
196         parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
197         checkinBuilder(janitor.release());
198         throw;
199     }
200 }
201
202 #endif
203
204 DOMDocument* ParserPool::parse(istream& is)
205 {
206     StreamInputSource src(is);
207     Wrapper4InputSource domsrc(&src,false);
208     return parse(domsrc);
209 }
210
211 // Functor to double its argument separated by a character and append to a buffer
212 template <class T> class doubleit {
213 public:
214     doubleit(T& t, const typename T::value_type& s) : temp(t), sep(s) {}
215     void operator() (const pair<const T,T>& s) { temp += s.first + sep + s.first + sep; }
216     T& temp;
217     const typename T::value_type& sep;
218 };
219
220 bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname)
221 {
222     // Just check the pathname and then directly register the pair into the map.
223
224     auto_ptr_char p(pathname);
225 #ifdef WIN32
226     struct _stat stat_buf;
227     if (_stat(p.get(), &stat_buf) != 0)
228 #else
229     struct stat stat_buf;
230     if (stat(p.get(), &stat_buf) != 0)
231 #endif
232     {
233 #if _DEBUG
234         xmltooling::NDC ndc("loadSchema");
235 #endif
236         Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool");
237         auto_ptr_char n(nsURI);
238         log.error("failed to load schema for (%s), file not found (%s)",n.get(),p.get());
239         return false;
240     }
241
242     // Roundtrip to local code page and back to translate path as needed.
243     string topath(p.get());
244     XMLToolingConfig::getConfig().getPathResolver()->resolve(topath, PathResolver::XMLTOOLING_XML_FILE);
245     auto_ptr_XMLCh temp(topath.c_str());
246
247     Lock lock(m_lock);
248     m_schemaLocMap[nsURI] = temp.get();
249     m_schemaLocations.erase();
250     for_each(m_schemaLocMap.begin(), m_schemaLocMap.end(), doubleit<xstring>(m_schemaLocations,chSpace));
251
252     return true;
253 }
254
255 bool ParserPool::loadCatalogs(const char* pathnames)
256 {
257     string temp(pathnames);
258     vector<string> catpaths;
259     split(catpaths, temp, is_any_of(PATH_SEPARATOR_STR), algorithm::token_compress_on);
260     static bool (ParserPool::* lc)(const char*) = &ParserPool::loadCatalog;
261     for_each(catpaths.begin(), catpaths.end(), boost::bind(lc, this, boost::bind(&string::c_str, _1)));
262     return !catpaths.empty();
263 }
264
265 bool ParserPool::loadCatalog(const char* pathname)
266 {
267     string p(pathname);
268     XMLToolingConfig::getConfig().getPathResolver()->resolve(p, PathResolver::XMLTOOLING_XML_FILE);
269     auto_ptr_XMLCh temp(p.c_str());
270     return loadCatalog(temp.get());
271 }
272
273 bool ParserPool::loadCatalog(const XMLCh* pathname)
274 {
275 #if _DEBUG
276     xmltooling::NDC ndc("loadCatalog");
277 #endif
278     Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool");
279
280     // XML constants
281     static const XMLCh catalog[] =  UNICODE_LITERAL_7(c,a,t,a,l,o,g);
282     static const XMLCh system[] =   UNICODE_LITERAL_6(s,y,s,t,e,m);
283     static const XMLCh systemId[] = UNICODE_LITERAL_8(s,y,s,t,e,m,I,d);
284     static const XMLCh uri[] =      UNICODE_LITERAL_3(u,r,i);
285     static const XMLCh CATALOG_NS[] = {
286         chLatin_u, chLatin_r, chLatin_n, chColon,
287         chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon,
288         chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon,
289         chLatin_t, chLatin_c, chColon,
290         chLatin_e, chLatin_n, chLatin_t, chLatin_i, chLatin_t, chLatin_y, chColon,
291         chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chColon,
292         chLatin_x, chLatin_m, chLatin_l, chColon,
293         chLatin_c, chLatin_a, chLatin_t, chLatin_a, chLatin_l, chLatin_o, chLatin_g, chNull
294     };
295
296     // Parse the catalog with the internal parser pool.
297
298     if (log.isDebugEnabled()) {
299         auto_ptr_char temp(pathname);
300         log.debug("loading XML catalog from %s", temp.get());
301     }
302
303     LocalFileInputSource fsrc(nullptr,pathname);
304     Wrapper4InputSource domsrc(&fsrc,false);
305     try {
306         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(domsrc);
307         XercesJanitor<DOMDocument> janitor(doc);
308
309         // Check root element.
310         const DOMElement* root=doc->getDocumentElement();
311         if (!XMLHelper::isNodeNamed(root,CATALOG_NS,catalog)) {
312             auto_ptr_char temp(pathname);
313             log.error("unknown root element, failed to load XML catalog from %s", temp.get());
314             return false;
315         }
316
317         // Fetch all the <system> elements.
318         DOMNodeList* mappings = root->getElementsByTagNameNS(CATALOG_NS,system);
319         Lock lock(m_lock);
320         for (XMLSize_t i = 0; i < mappings->getLength(); i++) {
321             root = static_cast<DOMElement*>(mappings->item(i));
322             const XMLCh* from = root->getAttributeNS(nullptr,systemId);
323             const XMLCh* to = root->getAttributeNS(nullptr,uri);
324
325             // Roundtrip to local code page and back to translate path as needed.
326             auto_ptr_char temp(to);
327             string topath(temp.get());
328             XMLToolingConfig::getConfig().getPathResolver()->resolve(topath, PathResolver::XMLTOOLING_XML_FILE);
329             auto_ptr_XMLCh temp2(topath.c_str());
330
331             m_schemaLocMap[from] = temp2.get();
332         }
333         m_schemaLocations.erase();
334         for_each(m_schemaLocMap.begin(), m_schemaLocMap.end(), doubleit<xstring>(m_schemaLocations,chSpace));
335     }
336     catch (std::exception& e) {
337         log.error("catalog loader caught exception: %s", e.what());
338         return false;
339     }
340
341     return true;
342 }
343
344 #ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS
345 DOMLSInput* ParserPool::resolveResource(
346             const XMLCh *const resourceType,
347             const XMLCh *const namespaceUri,
348             const XMLCh *const publicId,
349             const XMLCh *const systemId,
350             const XMLCh *const baseURI
351             )
352 #else
353 DOMInputSource* ParserPool::resolveEntity(
354     const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI
355     )
356 #endif
357 {
358 #if _DEBUG
359     xmltooling::NDC ndc("resolveEntity");
360 #endif
361     if (!systemId)
362         return nullptr;
363     xstring sysId(systemId);
364
365     Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool");
366     if (log.isDebugEnabled()) {
367         auto_ptr_char sysId(systemId);
368         auto_ptr_char base(baseURI);
369         log.debug("asked to resolve %s with baseURI %s",sysId.get(),base.get() ? base.get() : "(null)");
370     }
371
372     // Find well-known schemas in the specified location.
373     map<xstring,xstring>::const_iterator i = m_schemaLocMap.find(sysId);
374     if (i != m_schemaLocMap.end())
375         return new Wrapper4InputSource(new LocalFileInputSource(baseURI, i->second.c_str()));
376
377     // Check for entity as a suffix of a value in the map.
378     bool (*p_ends_with)(const xstring&, const xstring&) = ends_with;
379     i = find_if(
380         m_schemaLocMap.begin(), m_schemaLocMap.end(),
381         boost::bind(p_ends_with, boost::bind(&map<xstring,xstring>::value_type::second, _1), boost::ref(sysId))
382         );
383     if (i != m_schemaLocMap.end())
384         return new Wrapper4InputSource(new LocalFileInputSource(baseURI, i->second.c_str()));
385
386     // We'll allow anything without embedded slashes.
387     if (XMLString::indexOf(systemId, chForwardSlash) == -1 && XMLString::indexOf(systemId, chBackSlash) == -1)
388         return new Wrapper4InputSource(new LocalFileInputSource(baseURI, systemId));
389
390     // Shortcircuit the request.
391     auto_ptr_char temp(systemId);
392     log.debug("unauthorized entity request (%s), blocking it", temp.get());
393     static const XMLByte nullbuf[] = {0};
394     return new Wrapper4InputSource(new MemBufInputSource(nullbuf, 0, systemId));
395 }
396
397 #ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS
398
399 DOMLSParser* ParserPool::createBuilder()
400 {
401     static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull };
402     DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype);
403     DOMLSParser* parser=static_cast<DOMImplementationLS*>(impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS,nullptr);
404     parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, m_namespaceAware);
405     if (m_schemaAware) {
406         parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, true);
407         parser->getDomConfig()->setParameter(XMLUni::fgXercesSchema, true);
408         parser->getDomConfig()->setParameter(XMLUni::fgDOMValidate, true);
409         parser->getDomConfig()->setParameter(XMLUni::fgXercesCacheGrammarFromParse, true);
410
411         // We build a "fake" schema location hint that binds each namespace to itself.
412         // This ensures the entity resolver will be given the namespace as a systemId it can check.
413         parser->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(m_schemaLocations.c_str()));
414     }
415     parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
416     parser->getDomConfig()->setParameter(XMLUni::fgXercesDisableDefaultEntityResolution, true);
417     parser->getDomConfig()->setParameter(XMLUni::fgDOMResourceResolver, dynamic_cast<DOMLSResourceResolver*>(this));
418     parser->getDomConfig()->setParameter(XMLUni::fgXercesSecurityManager, m_security.get());
419     return parser;
420 }
421
422 DOMLSParser* ParserPool::checkoutBuilder()
423 {
424     Lock lock(m_lock);
425     if (m_pool.empty()) {
426         DOMLSParser* builder=createBuilder();
427         return builder;
428     }
429     DOMLSParser* p=m_pool.top();
430     m_pool.pop();
431     if (m_schemaAware)
432         p->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(m_schemaLocations.c_str()));
433     return p;
434 }
435
436 void ParserPool::checkinBuilder(DOMLSParser* builder)
437 {
438     if (builder) {
439         Lock lock(m_lock);
440         m_pool.push(builder);
441     }
442 }
443
444 #else
445
446 DOMBuilder* ParserPool::createBuilder()
447 {
448     static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull };
449     DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype);
450     DOMBuilder* parser=static_cast<DOMImplementationLS*>(impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,0);
451     parser->setFeature(XMLUni::fgDOMNamespaces, m_namespaceAware);
452     if (m_schemaAware) {
453         parser->setFeature(XMLUni::fgDOMNamespaces, true);
454         parser->setFeature(XMLUni::fgXercesSchema, true);
455         parser->setFeature(XMLUni::fgDOMValidation, true);
456         parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
457
458         // We build a "fake" schema location hint that binds each namespace to itself.
459         // This ensures the entity resolver will be given the namespace as a systemId it can check.
460         parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(m_schemaLocations.c_str()));
461     }
462     parser->setProperty(XMLUni::fgXercesSecurityManager, m_security.get());
463     parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
464     parser->setFeature(XMLUni::fgXercesDisableDefaultEntityResolution, true);
465     parser->setEntityResolver(this);
466     return parser;
467 }
468
469 DOMBuilder* ParserPool::checkoutBuilder()
470 {
471     Lock lock(m_lock);
472     if (m_pool.empty()) {
473         DOMBuilder* builder=createBuilder();
474         return builder;
475     }
476     DOMBuilder* p=m_pool.top();
477     m_pool.pop();
478     if (m_schemaAware)
479         p->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(m_schemaLocations.c_str()));
480     return p;
481 }
482
483 void ParserPool::checkinBuilder(DOMBuilder* builder)
484 {
485     if (builder) {
486         Lock lock(m_lock);
487         m_pool.push(builder);
488     }
489 }
490
491 #endif
492
493 StreamInputSource::StreamInputSource(istream& is, const char* systemId) : InputSource(systemId), m_is(is)
494 {
495 }
496
497 BinInputStream* StreamInputSource::makeStream() const
498 {
499     return new StreamBinInputStream(m_is);
500 }
501
502 StreamInputSource::StreamBinInputStream::StreamBinInputStream(istream& is) : m_is(is), m_pos(0)
503 {
504 }
505
506 #ifdef XMLTOOLING_XERCESC_64BITSAFE
507 XMLFilePos
508 #else
509 unsigned int
510 #endif
511 StreamInputSource::StreamBinInputStream::curPos() const
512 {
513     return m_pos;
514 }
515
516 #ifdef XMLTOOLING_XERCESC_64BITSAFE
517 const XMLCh* StreamInputSource::StreamBinInputStream::getContentType() const
518 {
519     return nullptr;
520 }
521 #endif
522
523 xsecsize_t StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const toFill, const xsecsize_t maxToRead)
524 {
525     XMLByte* target=toFill;
526     xsecsize_t bytes_read=0,request=maxToRead;
527
528     // Fulfill the rest by reading from the stream.
529     if (request && !m_is.eof() && !m_is.fail()) {
530         try {
531             m_is.read(reinterpret_cast<char* const>(target),request);
532             m_pos+=m_is.gcount();
533             bytes_read+=m_is.gcount();
534         }
535         catch(ios_base::failure& e) {
536             Category::getInstance(XMLTOOLING_LOGCAT".StreamInputSource").critStream()
537                 << "XML::StreamInputSource::StreamBinInputStream::readBytes caught an exception: " << e.what()
538                 << logging::eol;
539             *toFill=0;
540             return 0;
541         }
542     }
543     return bytes_read;
544 }
545
546 #ifdef XMLTOOLING_LITE
547
548 URLInputSource::URLInputSource(const XMLCh* url, const char* systemId, string* cacheTag) : InputSource(systemId), m_url(url)
549 {
550 }
551
552 URLInputSource::URLInputSource(const DOMElement* e, const char* systemId, string* cacheTag) : InputSource(systemId)
553 {
554     static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);
555     static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l);
556
557     const XMLCh* attr = e->getAttributeNS(nullptr, url);
558     if (!attr || !*attr) {
559         attr = e->getAttributeNS(nullptr, uri);
560         if (!attr || !*attr)
561             throw IOException("No URL supplied via DOM to URLInputSource constructor.");
562     }
563
564     m_url.setURL(attr);
565 }
566
567 BinInputStream* URLInputSource::makeStream() const
568 {
569     // Ask the URL to create us an appropriate input stream
570     return m_url.makeNewStream();
571 }
572
573 #else
574
575 URLInputSource::URLInputSource(const XMLCh* url, const char* systemId, string* cacheTag)
576     : InputSource(systemId), m_cacheTag(cacheTag), m_url(url), m_root(nullptr)
577 {
578 }
579
580 URLInputSource::URLInputSource(const DOMElement* e, const char* systemId, string* cacheTag)
581     : InputSource(systemId), m_cacheTag(cacheTag), m_root(e)
582 {
583 }
584
585 BinInputStream* URLInputSource::makeStream() const
586 {
587     return m_root ? new CurlURLInputStream(m_root, m_cacheTag) : new CurlURLInputStream(m_url.get(), m_cacheTag);
588 }
589
590 #endif
591
592 const char URLInputSource::asciiStatusCodeElementName[] = "URLInputSourceStatus";
593
594 const XMLCh URLInputSource::utf16StatusCodeElementName[] = UNICODE_LITERAL_20(U,R,L,I,n,p,u,t,S,o,u,r,c,e,S,t,a,t,u,s);