tags:

views:

60

answers:

1

When calling the function clojure.xml/parse with an URI Clojure performs a HTTP GET request to fetch the data. However the HTTP request contains the following accept headers:

text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Shouldn't this be application/xml?

+1  A: 

Calling clojure.xml/parse with a String parameter (URI) is similar to this java code:

SAXParserFactory.newInstance().newSAXParser().parse("<your_uri>", <instance of XMLHandler provided by Clojure>);

Clojure does not perform a HTTP GET request. It just uses SAX parser as default parser. Sax parser internally creates an instance of XMLInputSource and passes it all the way down to XMLEntityManager. Class XMLEntityManager does all the work related to opening connection and getting your xml (or more like html) document:

URL location = new URL(expandedSystemId); 
URLConnection connect = location.openConnection();
... skip ...
stream = connect.getInputStream();

If XmlInputSource is an instance of HTTPInputSource, then XMLEntityManager sets up HTTP request properties. However, there is no similar functionality for XMLInputSource (which is what we have in case of SAXParser).

I guess you what might help you is changing your SAX parser to some other implementation.

Georgy Bolyuba