From 151f339844a73a6c7476fa3b638ce95af1776bbb Mon Sep 17 00:00:00 2001 From: Lyrisbee Date: Fri, 1 Dec 2023 09:56:49 +0800 Subject: [PATCH] chore: apply changes --- src/Requests/Request.php | 14 ++++++++------ src/WordPress.php | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Requests/Request.php b/src/Requests/Request.php index 2704988..92f7106 100644 --- a/src/Requests/Request.php +++ b/src/Requests/Request.php @@ -36,14 +36,16 @@ protected function request( string $path, array $options = [], ): stdClass|array|bool { - $response = $this - ->app - ->http + $http = $this->app->http ->withoutVerifying() ->withoutRedirecting() - ->withUserAgent($this->app->userAgent()) - ->withBasicAuth($this->app->username(), $this->app->password()) - ->{$method}($this->getUrl($path), $options); + ->withBasicAuth($this->app->username(), $this->app->password()); + + if ($this->app->userAgent()) { + $http->withUserAgent($this->app->userAgent()); + } + + $response = $http->{$method}($this->getUrl($path), $options); if (!($response instanceof Response)) { throw new UnexpectedValueException(); diff --git a/src/WordPress.php b/src/WordPress.php index 87fc08f..465b831 100644 --- a/src/WordPress.php +++ b/src/WordPress.php @@ -29,7 +29,7 @@ class WordPress protected string $password; - protected string $userAgent = 'Storipress/WordPress/2023-12-01'; + protected ?string $userAgent; public function __construct( public Factory $http, @@ -111,7 +111,7 @@ public function tag(): Tag return $this->tag; } - public function userAgent(): string + public function userAgent(): ?string { return $this->userAgent; }