When no HTTP Accept, return XML by default#1405
Conversation
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
Pull request overview
Adjusts REST content negotiation so TEI XML is the default response when clients omit an Accept header (fixing #1093), while still supporting explicit BibTeX responses via Accept: application/x-bibtex.
Changes:
- Lowered the server-side quality factor for BibTeX
@Producesmedia types (;qs=0.5) so XML wins whenAcceptis missing/*/*. - Applied the same negotiation tweak consistently across header, citation, citation list, and references BibTeX endpoints.
Comments suppressed due to low confidence (1)
grobid-service/src/main/java/org/grobid/service/GrobidRestService.java:702
- The server-side quality factor string (";qs=0.5") is duplicated across multiple
@Producesannotations in this class. Consider extracting it into a single constant (e.g., alongside BibTexMediaType.MEDIA_TYPE) to avoid drift if you ever need to adjust the default negotiation priority again.
@Path(PATH_CITATION_LIST)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(BibTexMediaType.MEDIA_TYPE + ";qs=0.5")
@POST
public Response processCitationListReturnBibTeX_post(
@FormParam(CITATION) List<String> citations,
@DefaultValue("0") @FormParam(CONSOLIDATE_CITATIONS) String consolidate,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
grobid-service/src/main/java/org/grobid/service/GrobidRestService.java:241
- The content-negotiation change affects
/api/processHeaderDocumentand/api/processReferencesas well, but the added regression tests only cover/api/processCitation. Please add at least one test that asserts the default response forPATH_HEADERis XML when no Accept is provided, and that BibTeX is returned whenAccept: application/x-bibtexis set, to directly cover issue #1093.
@Path(PATH_HEADER)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(BibTexMediaType.MEDIA_TYPE + ";qs=0.5")
@POST
public Response processHeaderDocumentReturnBibTeX_post(
@FormDataParam(INPUT) InputStream inputStream,
@DefaultValue("0") @FormDataParam(CONSOLIDATE_HEADER) String consolidate,
@DefaultValue("0") @FormDataParam(INCLUDE_RAW_AFFILIATIONS) String includeRawAffiliations,
@DefaultValue("0") @FormDataParam(INCLUDE_RAW_COPYRIGHTS) String includeRawCopyrights,
@DefaultValue("0") @FormDataParam("start") int startPage,
@DefaultValue("2") @FormDataParam("end") int endPage) {
int consol = validateConsolidationParam(consolidate);
return restProcessFiles.processStatelessHeaderDocument(
inputStream,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #1093