Skip to content

Include version number and website URL in HTTP User-Agent header#1914

Merged
osma merged 2 commits intomainfrom
set-user-agent-version
Jan 29, 2026
Merged

Include version number and website URL in HTTP User-Agent header#1914
osma merged 2 commits intomainfrom
set-user-agent-version

Conversation

@osma
Copy link
Member

@osma osma commented Jan 29, 2026

Reasons for creating this PR

Previously, Skosmos only used the User-Agent header Skosmos without any further information. This does not follow relevant recommendations and conventions, and may cause difficulties in analyzing and controlling web traffic.

This PR adds the version number and https://skosmos.org URL to the User-Agent header used in SPARQL, Linked Data, LOC and WDQS requests. A PHPUnit test verifies that it is generated properly.

The "Skosmos" user-agent header was implemented in #1691. Back then we decided not to include the version number:

I decided not to include the Skosmos version number in the user-agent string based on discussion with other Skosmos developers.

Link to relevant issue(s), if any

Description of the changes in this PR

  • add Model.getUserAgent() method that generates the User-Agent header value
  • use that method to construct user-agent value in GenericSparql, LinkedDataResolver, LOCResolver and WDQSResolver
  • add PHPUnit test to verify that the header value is properly generated

Known problems or uncertainties in this PR

I didn't include a test that would verify that the user-agent setting is actually used in HTTP requests. That would probably be possible with Cypress (by intercepting requests) but IMHO it's a lot of work for little benefit.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added this to the 3.1 milestone Jan 29, 2026
@osma osma requested a review from miguelvaara January 29, 2026 09:00
@osma osma self-assigned this Jan 29, 2026
@osma osma moved this to Under review in Skosmos 3.x Backlog Jan 29, 2026
@sonarqubecloud
Copy link

Copy link
Contributor

@miguelvaara miguelvaara left a comment

Choose a reason for hiding this comment

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

Everything seems to be working well. Thanks @osma! I think you can go ahead and merge.

@osma osma merged commit 4d120d2 into main Jan 29, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from Under review to Issue/PR closed in Skosmos 3.x Backlog Jan 29, 2026
@osma osma deleted the set-user-agent-version branch January 29, 2026 11:04
Copy link
Contributor

@miguelvaara miguelvaara left a comment

Choose a reason for hiding this comment

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

I also used a small PHP script to monitor traffic while loading mappings on the concept page and the result was as follows:

User-Agent: Skosmos/3.1-dev (https://skosmos.org/)
Accept: application/sparql-results+json,application/sparql-results+xml;q=0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants