geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
499 stars 261 forks source link

content negotiation should check first matching #577

Closed pvgenuchten closed 7 months ago

pvgenuchten commented 3 years ago

Description if you send a combined accept header of plain/text, application/ld+json a json response is returned (i guess json is the catch all format returned for unknown encodings). Expected is to return a json-ld encoding as it is the first match with any of the encodings available in pygeoapi

Steps to Reproduce I used poster in chrome to send various accept headers I arrived at this issue when testing microdata using http://linter.structured-data.org, they send a long accept header with various ld types and html, but json is returned, leading to a parse error

Expected behavior pygeoapi returns the encoding for which it finds the first match in the list of requested and available encodings

Screenshots/Tracebacks

image

image

Environment

ksonda commented 3 years ago

I believe we're running up into this or a related issue as part of a search indexing experiment making heavy use of pygeoapi.

https://github.com/internetofwater/harvest.geoconnex.us/issues/3

I believe the problem is here. https://github.com/geopython/pygeoapi/blob/master/pygeoapi/api.py#L89

I think pygeoapi isn't really doing content negotiation via accept header order. It defaults to json if there's no accept header, and has a hard-coded priority of text/html, json+ld, then json if there is.

This is a high priority for us to fix.

webb-ben commented 3 years ago

This is now addressed in #795

pvgenuchten commented 2 years ago

I think pygeoapi isn't really doing content negotiation via accept header order. It defaults to json if there's no accept header, and has a hard-coded priority of text/html, json+ld, then json if there is.

i got same impression, the behaviour must have been changed a while ago, we have structured data results at least up to march 2020, but currently structured data parsing, at least on google is broken, in my impression it is related to above statement, not providing a accept encoding causes pygeoapi to return json

ksonda commented 2 years ago

Since the changes above Our own crawler harvests our pygeoapi urls ok. We haven't gotten any results from Google since the introduction of Rich Results test tool and retirement of the structured data test tool. It seems like google is not indexing structured content based on @type

github-actions[bot] commented 8 months ago

As per RFC4, this Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] commented 7 months ago

As per RFC4, this Issue has been closed due to there being no activity for more than 90 days.