summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-11-28 10:08:07 -0100
committerMaxence Lange <maxence@artificial-owl.com>2018-11-28 10:08:07 -0100
commitb27e31ad5d4b1231da206c353f9392b7dd6e0aed (patch)
tree598d264ef65190249822158a6d17d95c99bc5865
parent527313d4a9237faf18cea8950bc35e91fa3e27be (diff)
user agent in requests
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--composer.lock8
-rw-r--r--lib/Service/CurlService.php9
2 files changed, 13 insertions, 4 deletions
diff --git a/composer.lock b/composer.lock
index 379b97db..b0c6dab8 100644
--- a/composer.lock
+++ b/composer.lock
@@ -12,12 +12,12 @@
"source": {
"type": "git",
"url": "https://github.com/daita/my-small-php-tools.git",
- "reference": "ba839f3253672defc4bbb181493c78e2c96e272a"
+ "reference": "12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/ba839f3253672defc4bbb181493c78e2c96e272a",
- "reference": "ba839f3253672defc4bbb181493c78e2c96e272a",
+ "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997",
+ "reference": "12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997",
"shasum": ""
},
"require": {
@@ -40,7 +40,7 @@
}
],
"description": "My small PHP Tools",
- "time": "2018-11-27T14:31:43+00:00"
+ "time": "2018-11-28T10:47:43+00:00"
}
],
"packages-dev": [],
diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php
index 3a420560..1aa94cc3 100644
--- a/lib/Service/CurlService.php
+++ b/lib/Service/CurlService.php
@@ -44,6 +44,7 @@ class CurlService {
const ASYNC_TOKEN = '/async/token/{token}';
+ const USER_AGENT = 'Nextcloud Social';
/** @var ConfigService */
@@ -104,6 +105,13 @@ class CurlService {
}
+ public function assignUserAgent(Request $request) {
+ $request->setUserAgent(
+ self::USER_AGENT . ' ' . $this->configService->getAppValue('installed_version')
+ );
+ }
+
+
/**
* @param string $token
*
@@ -139,6 +147,7 @@ class CurlService {
$headers[] = 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
+ curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);