Repository navigation
Add support for Guzzle 8 - #430
Merged
Merged
Conversation
Allow guzzlehttp/guzzle ^8.0, guzzlehttp/promises ^3.0 and guzzlehttp/psr7 ^3.0 alongside the existing Guzzle 7 constraints (#429). * Fix unsigned upload without `api_key`/`api_secret` (send no Basic auth when credentials are missing) * Cast request header values to strings; skip unnamed (list-form) `headers` entries in HTTP request headers * Handle any `Throwable` rejection from the HTTP client * Test against both Guzzle 7 and Guzzle 8 in CI Notes for Guzzle 8 users: * Connect timeout defaults to 60 seconds when `connection_timeout` is not set * Read timeouts are reported as `NetworkTimeoutException`, which is not a `ConnectException` * Multipart parts no longer carry a per-part `Content-Length` header Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Summary of Changes
Allow Guzzle 8 alongside Guzzle 7:
guzzlehttp/guzzle ^7.4.5|^8.0,guzzlehttp/promises ^1.5.3|^2.0|^3.0,guzzlehttp/psr7 ^2.7|^3.0. Existing Guzzle 7 users are unaffected; Guzzle 7 remains in maintenance upstream.Code changes needed for Guzzle 8 (all also apply on Guzzle 7):
ApiClient::buildHttpClientConfig: send theauthoption only when bothapi_keyandapi_secretare set. Guzzle 8 rejectsnullauth values. This also fixes unsigned upload when no credentials are configured, which currently fails with401on Guzzle 7 as well.BaseApiClient::callAsync: cast request header values to strings (Guzzle 8 rejects non-string values) and skip unnamed entries. The list form of theheadersupload parameter (['X-Robots-Tag: noindex']) is still sent to the API as the parameter, but is no longer added to the HTTP request headers (Guzzle 7 sent it as a header named0; Guzzle 8 throws).BaseApiClient::callAsync: the rejection handler accepts anyThrowable, since Guzzle 8 also rejects with non-Exceptionerrors.ApiConfig::$connectionTimeout: docblock describes the Guzzle 7 / Guzzle 8 defaults.Behavior changes coming from Guzzle 8 itself, for the release notes:
connection_timeoutis not set (libcurl default was 300).NetworkTimeoutException, which is not aConnectException.Content-Lengthheader (RFC 7578 §4.8).composer update; to stay on 7:composer require guzzlehttp/guzzle:^7.What does this PR address?
Are tests included?
Reviewer, please note:
AssetsTest::testVisualSearchImageFileasserted the per-partContent-Lengththat psr7 3 no longer generates. It now checks theimage_filemultipart option directly (exact file bytes and filename), which works on both majors.Checks from #429
headers/extra_headersare cast to strings inBaseApiClient::normalizeHeaders; SDK-set headers (User-Agent,Authorization,X-Unique-Upload-Id,Content-Range) were already strings.requestAsync()with uppercase constants fromHttpMethod.Content-Lengthis no longer sent (see above);", CR and LF in multipart file names are escaped as%22,%0D,%0A;Urirejects a few more malformed URLs.LimitStreamandUtils::streamForbehavior used by chunked upload is unchanged;UploadApiTest::testUploadLargecovers it in CI.*Async()return types are unchanged. One behavior change: a rejection handler attached to an SDK promise after the request has already failed is now invoked (promises 2 skipped it).Checklist:
Closes #429
🤖 Generated with Claude Code