Set HTTP user-agent to 'Skosmos' when performing requests#1711
Merged
Conversation
|
miguelvaara
reviewed
Dec 12, 2024
Contributor
miguelvaara
left a comment
There was a problem hiding this comment.
How I tested
In the command line:
sudo ngrep -q -W byline 'User-Agent' tcp port 80
In the browser's address bar:
http://localhost/skosmos/yso/en/page/p26179 (A-clinics)
Result:
interface: wlp0s20f3 (192.168.XXX.XXX/255.255.255.0)
filter: ( tcp port 80 ) and ((ip || ip6) || (vlan && (ip || ip6)))
match (JIT): User-Agent
T 192.168.XXX.XXX:53316 -> 128.214.XXX.XXX:80 [AP] #6
Host: api.dev.finto.fi.
Connection: close.
User-Agent: Skosmos.
Accept: application/sparql-results+json,application/sparql-results+xml;q=0.8.
.
T 192.168.XXX.XXX:53320 -> 128.214.XXX.XXX:80 [AP] #17
Host: api.dev.finto.fi.
Connection: close.
User-Agent: Skosmos.
Accept: application/sparql-results+json,application/sparql-results+xml;q=0.8.
.
T 192.168.XXX.XXX:53322 -> 128.214.XXX.XXX:80 [AP] #28
Host: api.dev.finto.fi.
Connection: close.
User-Agent: Skosmos.
Accept: application/sparql-results+json,application/sparql-results+xml;q=0.8.
.
T 192.168.XXX.XXX:53326 -> 128.214.XXX.XXX:80 [AP] #39
Host: api.dev.finto.fi.
Connection: close.
User-Agent: Skosmos.
Accept: application/sparql-results+json,application/sparql-results+xml;q=0.8.
...etc (a longer list is not meaningful because it works in all cases)
The code also looks meaningful.
Well done! 👍 In my opinion, it can be merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Reasons for creating this PR
See #1691. It's good practice to use a custom HTTP user agent instead of relying on library defaults. This code sets the user-agent to
Skosmosevery time EasyRdf is used to perform HTTP requests (including SPARQL). There is one more place in the code (LOCResolver) that performs HTTP requests directly using stream operations, but in that code the user-agent was already set toSkosmos.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
Known problems or uncertainties in this PR
No unit tests, but I don't think it's easy to test this with PHPUnit. However, I tested manually that the changes do have an effect by looking at HTTP server logs.
Checklist
.sr-onlyclass, color contrast)