pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

content negotiation should check first matching

Open pvgenuchten opened this issue 4 years ago • 4 comments

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

  • pygeoapi version: .8

pvgenuchten avatar Nov 19 '20 16:11 pvgenuchten

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.

ksonda avatar Oct 18 '21 13:10 ksonda

This is now addressed in #795

webb-ben avatar Oct 18 '21 16:10 webb-ben

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

pvgenuchten avatar May 15 '22 09:05 pvgenuchten

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

ksonda avatar May 15 '22 16:05 ksonda

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] avatar Mar 10 '24 21:03 github-actions[bot]

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

github-actions[bot] avatar Mar 24 '24 03:03 github-actions[bot]