Skip to content

Upgrade guzzle#2

Merged
addelong merged 1 commit intomasterfrom
upgrade-guzzle
Jul 18, 2024
Merged

Upgrade guzzle#2
addelong merged 1 commit intomasterfrom
upgrade-guzzle

Conversation

@addelong
Copy link

No description provided.

* @return string
*/
public function getApiUrl() {
public function getApiUrl(): string
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a few changes in this PR that are the result of hitting the "Cleanup code" button in PHPStorm which basically amounts to adding a return type signature to functions. Just a heads up.

"php": ">=5.4",
"guzzle/http": ">=3.6.0,<4"
"guzzlehttp/guzzle": "~6.3.3",
"ext-json": "*"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though ext-json is present by default, it is apparently best practice to explicitly list it as a requirement if you use things like json_decode.

Copy link

@TomasRebro TomasRebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 I just have one question to better understand that specific change.

$response = $this->getHttpClient()->post($path, [
'body' => $body,
'headers' => [
'Content-Type' => $contentType ?: 'application/octet-stream'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this default content type automatically set behind the scenes before? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually know, because the API docs for guzzle3 have gone offline, I can't find a version on archive.org that has documentation for Guzzle's version of addPostFile, and the the old PHP docs for the built-in version of addPostFile mark contentType as optional. BUT, I do see in the archived Guzzle docs that it had a protected guessContentType() function, so my best guess is that yes, it was at least trying to set something behind the scenes. And application/octet-stream is the content type for "I don't really know what this is, here's a bunch of binary data", so it seemed like the most appropriate option.

Either way, pragmatically, it doesn't seem like we're actually going to run into a case where contentType is not supplied to this function.

@addelong addelong merged commit 74079e5 into master Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants