diff --git a/src/Console/Command/WorkerCommand.php b/src/Console/Command/WorkerCommand.php index b7d978e1..a9652d01 100644 --- a/src/Console/Command/WorkerCommand.php +++ b/src/Console/Command/WorkerCommand.php @@ -18,10 +18,10 @@ class WorkerCommand extends AbstractCommand public function run(?string $connection = null): void { $tries = (int) $this->arg->getParameter('--tries', 3); - $default = $this->arg->getParameter('--queue', "default"); + $queue_name = $this->arg->getParameter('--queue', "default"); $memory = (int) $this->arg->getParameter('--memory', 126); $timout = (int) $this->arg->getParameter('--timout', 3); - $sleep = (int) $this->arg->getParameter('--sleep', 60); + $sleep = (int) $this->arg->getParameter('--sleep', 3); $queue = app("queue"); @@ -31,7 +31,7 @@ public function run(?string $connection = null): void $worker = $this->getWorderService(); $worker->setConnection($queue->getAdapter()); - $worker->run($default, $tries, $sleep, $timout, $memory); + $worker->run($queue_name, $tries, $sleep, $timout, $memory); } /** diff --git a/src/Http/Client/HttpClient.php b/src/Http/Client/HttpClient.php index d1852598..c905043d 100644 --- a/src/Http/Client/HttpClient.php +++ b/src/Http/Client/HttpClient.php @@ -260,7 +260,7 @@ private function addFields(array $data): void return; } - if ($this->accept_json) { + if ($this->accept_json || $this->hasHeader('content-type', 'application/json')) { $payload = json_encode($data); } else { $payload = http_build_query($data); @@ -377,12 +377,28 @@ public function setUserAgent(string $user_agent): HttpClient /** * Configure client to accept and send JSON data * + * @deprecated 5.2.99 * @return HttpClient */ public function acceptJson(): HttpClient { $this->accept_json = true; + $this->withHeaders(["Content-Type" => "application/json"]); + $this->withHeaders(["Accept" => "application/json"]); + + return $this; + } + + /** + * Configure client to accept and send JSON data + * + * @return HttpClient + */ + public function withJson(): HttpClient + { + $this->accept_json = true; + $this->withHeaders(["Content-Type" => "application/json"]); return $this; @@ -398,13 +414,25 @@ public function withHeaders(array $headers): HttpClient { foreach ($headers as $key => $value) { if (!in_array(strtolower($key . ': ' . $value), array_map('strtolower', $this->headers))) { - $this->headers[] = $key . ': ' . $value; + $this->headers[] = trim($key) . ': ' . $value; } } return $this; } + /** + * Check if header exists + * + * @param string $key + * @param string $value + * @return boolean + */ + public function hasHeader(string $key, string $value): bool + { + return in_array(strtolower($key . ': ' . $value), array_map('strtolower', $this->headers)); + } + /** * Set HTTP authentication credentials * diff --git a/src/Http/UploadedFile.php b/src/Http/UploadedFile.php index 4ebfdcc4..bfd4ad51 100644 --- a/src/Http/UploadedFile.php +++ b/src/Http/UploadedFile.php @@ -41,7 +41,7 @@ public function getExtension(): ?string if (!$this->isUploaded()) { return null; } - + if (!isset($this->file['name'])) { return null; } diff --git a/src/Queue/Adapters/QueueAdapter.php b/src/Queue/Adapters/QueueAdapter.php index 68777212..32ca6e81 100644 --- a/src/Queue/Adapters/QueueAdapter.php +++ b/src/Queue/Adapters/QueueAdapter.php @@ -297,13 +297,13 @@ public function getQueue(?string $queue = null): string } /** - * Watch the queue name + * Set the queue name * * @param string $queue */ public function setQueue(string $queue): void { - // + $this->queue = $queue; } /**