File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -342,7 +342,8 @@ def getXMLTree(rsp: ResponseWrapper) -> etree:
342342 et = etree .fromstring (raw_text )
343343
344344 # check for response type - if it is not xml then raise an error
345- content_type = rsp .info ()['Content-Type' ]
345+ # if the server doesn't provide a Content-Type then assume xml
346+ content_type = rsp .info ().get ('Content-Type' , 'text/xml' )
346347 url = rsp .geturl ()
347348
348349 xml_types = ['text/xml' , 'application/xml' , 'application/vnd.ogc.wms_xml' ]
Original file line number Diff line number Diff line change @@ -71,6 +71,19 @@ def test_getXMLTree_valid():
7171 assert et .find ('.//Title' ).text == "Example"
7272
7373
74+ def test_getXMLTree_valid_missing_content_type ():
75+
76+ mock_resp = mock .Mock ()
77+ mock_resp .url = 'http:///example.org/?service=WFS&request=GetCapabilities&version=2.0.0'
78+ mock_resp .content = b'<?xml version="1.0" encoding="UTF-8"?>\n <WFS_Capabilities><ServiceIdentification>' \
79+ b'<Title>Example</Title></ServiceIdentification></WFS_Capabilities>'
80+ mock_resp .headers = {}
81+ resp_wrap = ResponseWrapper (mock_resp )
82+
83+ et = getXMLTree (resp_wrap )
84+ assert et .find ('.//Title' ).text == "Example"
85+
86+
7487def test_getXMLTree_invalid ():
7588
7689 mock_resp = mock .Mock ()
You can’t perform that action at this time.
0 commit comments