Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Wizard in XML Mode forcing Accept header to application/xml #133

Open
sgrellet opened this issue Mar 11, 2021 · 0 comments
Open

Load Wizard in XML Mode forcing Accept header to application/xml #133

sgrellet opened this issue Mar 11, 2021 · 0 comments
Assignees
Labels
bug Houston, we've a problem!
Milestone

Comments

@sgrellet
Copy link
Member

Environment

  • Plugin version: 1.3.1
  • QGIS version: 3.16.2-Hannover Hannover, f1660f9da5
  • Operating System: Windows 10
  • Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]

Description

  • when accessing URLs(URIs) in 'XML Mode' via the 'Load Wizard', the Accept header is set to application/xml instead of either nothing (to allow passing a GET param like f=application%2Fgml%2Bxml) or directly application/gml+xml
  • this may cause issues when content negociation happens with the server.

To Reproduce

Steps to reproduce the behavior:

  1. Load Wizard > File/URL : http://iddata.eaufrance.fr/id/HydroStation/A021005050
  2. Loading options > 'Load in XML mode'
  3. Next and Finish

-> Python error
Stack trace below

Expected behavior

  • The GML content is properly fetched from the URL/I and added to the QGIS Layer

Additional context

  • QGIS 'Network Logger' (F12) shows an Accept header set to application/xml
  • querying that URI in a application such as PostMan with Accept header set to application/xml leads to the following error => {"code": "NoApplicableCode", "description": "Could not find acceptable representation"}
  • querying that URI in a application such as PostMan with Accept header set to application/gml+xml allows to fetch the GML representation

Logs

AttributeError: 'NoneType' object has no attribute 'close' 
Traceback (most recent call last):
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 386, in load_complex_gml
    src = ComplexFeatureSource(xml_src, attributes, geometry_mapping, logger)
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 249, in __init__
    doc, _ = xml_parse(xml)
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\xml_utils.py", line 118, in xml_parse
    for event, elem in ET.iterparse(xml_file, ["start-ns", "start", "end"]):
  File "C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\xml\etree\ElementTree.py", line 1243, in iterparse
    source = open(source, "rb")
TypeError: expected str, bytes or os.PathLike object, not NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_wizard_xml.py", line 79, in validatePage
    swap_xy=self.swapXYCheck.isChecked(),
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 71, in load_as_xml_layer
    xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy
  File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 468, in load_complex_gml
    xml_src.close()
AttributeError: 'NoneType' object has no attribute 'close'
@sgrellet sgrellet added the bug Houston, we've a problem! label Mar 11, 2021
@sgrellet sgrellet changed the title XML Mode forcing Accept header to application/xml Load Wizard in XML Mode forcing Accept header to application/xml Mar 11, 2021
@Guts Guts added this to the 1.3.2 milestone Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Houston, we've a problem!
Projects
None yet
Development

No branches or pull requests

2 participants