Skip to content

When no HTTP Accept, return XML by default#1405

Merged
lfoppiano merged 4 commits into
masterfrom
bugfix/add-priority-content-type
Mar 31, 2026
Merged

When no HTTP Accept, return XML by default#1405
lfoppiano merged 4 commits into
masterfrom
bugfix/add-priority-content-type

Conversation

@lfoppiano

Copy link
Copy Markdown
Member

Fixes #1093

Signed-off-by: Luca Foppiano <luca@foppiano.org>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @Produces media types (;qs=0.5) so XML wins when Accept is 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 @Produces annotations 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/processHeaderDocument and /api/processReferences as well, but the added regression tests only cover /api/processCitation. Please add at least one test that asserts the default response for PATH_HEADER is XML when no Accept is provided, and that BibTeX is returned when Accept: application/x-bibtex is 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lfoppiano lfoppiano merged commit 6b77a4e into master Mar 31, 2026
13 checks passed
@lfoppiano lfoppiano deleted the bugfix/add-priority-content-type branch March 31, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

processHeaderDocument returns BibTeX by default instead of TEI

2 participants