Skip to content

Commit

Permalink
Ensured */* Accept headers always match for OPDS1
Browse files Browse the repository at this point in the history
Allow /groups to also be OPDS2 if requested
  • Loading branch information
RishiDiwanTT committed Sep 14, 2023
1 parent e3ecb1c commit bef06fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def groups(self, lane_identifier, feed_class=OPDSAcquisitionFeed):
annotator=annotator,
facets=facets,
search_engine=search_engine,
).as_response()
).as_response(mime_types=flask.request.accept_mimetypes)

def feed(self, lane_identifier, feed_class=OPDSAcquisitionFeed):
"""Build or retrieve a paginated acquisition feed.
Expand Down
5 changes: 2 additions & 3 deletions core/feed/opds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
def get_serializer(
mime_types: Optional[MIMEAccept],
) -> SerializerInterface[Any]:
# Loop through and return whichever mimetype is encountered first
# Sort values by q-value first
# Ordering matters for poor matches (eg. */*), so we will keep OPDS1 first
serializers: Dict[str, Type[SerializerInterface[Any]]] = {
"application/opds+json": OPDS2Serializer,
"application/atom+xml": OPDS1Serializer,
"application/opds+json": OPDS2Serializer,
}
if mime_types:
match = mime_types.best_match(

Check warning on line 26 in core/feed/opds.py

View check run for this annotation

Codecov / codecov/patch

core/feed/opds.py#L26

Added line #L26 was not covered by tests
Expand Down

0 comments on commit bef06fe

Please sign in to comment.