File tree 2 files changed +15
-1
lines changed
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:
342
342
et = etree .fromstring (raw_text )
343
343
344
344
# 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' )
346
347
url = rsp .geturl ()
347
348
348
349
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():
71
71
assert et .find ('.//Title' ).text == "Example"
72
72
73
73
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
+
74
87
def test_getXMLTree_invalid ():
75
88
76
89
mock_resp = mock .Mock ()
You can’t perform that action at this time.
0 commit comments