Skip to content

Conversation

@koushikch7
Copy link

Fixes #40157

Description

Adds support for missing HTTP methods in the Curl HTTP client implementation as per RFC 9110 (HTTP semantics) and RFC 5789 (PATCH method).

Methods Added

  • PUT - RFC 9110 Section 9.3
  • DELETE - RFC 9110 Section 9.7
  • PATCH - RFC 5789
  • OPTIONS - RFC 9110 Section 9.1
  • HEAD - RFC 9110 Section 9.2
  • TRACE - RFC 9110 Section 9.8
  • CONNECT - RFC 9110 Section 9.9

Changes

  • Added HTTP_METHODS_WITH_PAYLOAD constant to identify methods supporting request bodies
  • Implemented all 7 missing HTTP methods with proper type hints
  • Refactored makeRequest() method using switch statement for cleaner code
  • Updated test helper delete() method signature to support optional parameters
  • Maintained backward compatibility with default parameters where applicable

Testing

  • All existing unit and integration tests pass
  • No breaking changes to existing API
  • RFC-compliant implementations

Related

Add PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, and CONNECT methods to the
Curl HTTP client class. These methods follow RFC 9110 standards for HTTP
semantics and are essential for working with modern APIs.

Changes:
1. Added HTTP_METHODS_WITH_PAYLOAD constant to identify methods that support
   request payloads (POST, PUT, PATCH, OPTIONS).

2. Implemented new public methods:
   - put(string $uri, string|array $params): void
   - delete(string $uri, array|string $params = []): void
   - patch(string $uri, array|string $params): void
   - options(string $uri, array|string $params = []): void
   - head(string $uri): void
   - trace(string $uri): void
   - connect(string $uri): void

3. Refactored makeRequest() to use switch statement for better method handling
   and to properly set CURLOPT_PUT for PUT requests.

4. Updated test framework Curl helper to match new delete() signature.

5. Added RFC references in docblocks for HTTP method specifications.

This implementation:
- Maintains backward compatibility with existing GET and POST methods
- Follows HTTP RFC specifications (RFC 9110, RFC 5789)
- Properly handles request payloads for all methods that support them
- Uses CURLOPT_PUT for PUT requests and CURLOPT_CUSTOMREQUEST for others

Fixes magento#40157
@m2-assistant
Copy link

m2-assistant bot commented Dec 24, 2025

Hi @koushikch7. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@koushikch7
Copy link
Author

@magento run all tests

@koushikch7
Copy link
Author

@magento run Functional Tests B2B,Semantic Version Checker

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.

[Issue] [2.4] Add support for missing Curl methods to the Curl client

1 participant