Merge pull request #62 from nextcloud-gmbh/user-agent

user agent in requests
pull/64/head
Maxence Lange 2018-11-28 10:08:41 -01:00 zatwierdzone przez GitHub
commit a43e0c31de
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 13 dodań i 4 usunięć

8
composer.lock wygenerowano
Wyświetl plik

@ -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": [],

Wyświetl plik

@ -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);