Skip to content

Commit

Permalink
Merge pull request #1711 from NatLibFi/issue1691-set-http-user-agent
Browse files Browse the repository at this point in the history
Set HTTP user-agent to 'Skosmos' when performing requests
  • Loading branch information
osma authored Dec 12, 2024
2 parents b44d677 + ac1caf9 commit bddba45
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/model/resolver/LinkedDataResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function resolve(int $timeout): ?EasyRdf\Resource
try {
// change the timeout setting for external requests
$httpclient = EasyRdf\Http::getDefaultHttpClient();
$httpclient->setConfig(array('timeout' => $timeout));
$httpclient->setConfig(array('timeout' => $timeout, 'useragent' => 'Skosmos'));
EasyRdf\Http::setDefaultHttpClient($httpclient);

$graph = EasyRdf\Graph::newAndLoad(EasyRdf\Utils::removeFragmentFromUri($this->uri));
Expand Down
2 changes: 1 addition & 1 deletion src/model/resolver/WDQSResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function resolve(int $timeout): ?EasyRdf\Resource
EasyRdf\Format::unregister('json');
// change the timeout setting for external requests
$httpclient = EasyRdf\Http::getDefaultHttpClient();
$httpclient->setConfig(array('timeout' => $timeout));
$httpclient->setConfig(array('timeout' => $timeout, 'useragent' => 'Skosmos'));
$httpclient->setHeaders('Accept', 'text/turtle');
EasyRdf\Http::setDefaultHttpClient($httpclient);

Expand Down
3 changes: 2 additions & 1 deletion src/model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ protected function initializeHttpClient()
{
// configure the HTTP client used by EasyRdf\Sparql\Client
$httpclient = EasyRdf\Http::getDefaultHttpClient();
$httpclient->setConfig(array('timeout' => $this->model->getConfig()->getSparqlTimeout()));
$httpclient->setConfig(array('timeout' => $this->model->getConfig()->getSparqlTimeout(),
'useragent' => 'Skosmos'));

// if special cache control (typically no-cache) was requested by the
// client, set the same type of cache control headers also in subsequent
Expand Down

0 comments on commit bddba45

Please sign in to comment.