mloesch / sickle

Sickle: OAI-PMH for Humans
Other
106 stars 42 forks source link

Add a warning if a server sends back non-XML #51

Open anthonybaxter opened 3 years ago

anthonybaxter commented 3 years ago

https://data.csiro.au/dap/ws/v2/collections is an example of a server that sends back JSON rather than XML to a sickle request by default.

Adding headers={'Accept': 'application/xml'} to the Sickle() constructor fixes that, but it was a bit of digging to work out why. This logging message would have saved me a bit of debugging time.

anthonybaxter commented 3 years ago

Hm. further adventures suggest if (self.http_response.headers.get('Content-Type').split(";")[0] .lower() not in ('text/xml', 'application/xml')): is more robust.