-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Add missing REST methods to Curl Client (SwiftOtter's SOP-348) #39330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
302f9b5
e3668e8
064aa04
0ec2621
2da6f81
d16233e
4297a88
9f32ea3
e71d63b
252c027
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* Copyright 2011 Adobe | ||
* All Rights Reserved. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\HTTP\Client; | ||
|
||
/** | ||
* Class to work with HTTP protocol using curl library | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) | ||
* @api | ||
*/ | ||
|
@@ -246,6 +244,89 @@ public function post($uri, $params) | |
$this->makeRequest("POST", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make PUT request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function put($uri, $params) | ||
{ | ||
$this->makeRequest("PUT", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make DELETE request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function delete(string $uri, array|string $params = []) | ||
{ | ||
$this->makeRequest("DELETE", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make PATCH request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function patch($uri, $params) | ||
{ | ||
$this->makeRequest("PATCH", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make OPTIONS request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function options(string $uri, array|string $params = []) | ||
{ | ||
$this->makeRequest("OPTIONS", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make HEAD request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function head(string $uri, array|string $params = []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not introduce a payload here because according to RFC9110
https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.2 You're absolutely correct that the RFC you linked doesn't explicitly forbid a payload for HEAD requests. However, it strongly discourages it and hints at the reasons why it's generally not used: Semantic Ambiguity:
Why GET can have a payload (though discouraged):While GET requests can technically have a payload, it's generally discouraged for similar reasons to HEAD. The RFC states that a payload in a GET request "has no semantic meaning to the request." This means the server is free to ignore it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @lbajsarowicz, Thanks for the detailed explanation. FYI, as mentioned in #39330 (review), I have added an optional payload for the DELETE, OPTIONS, and HEAD methods. Additionally, I have added the CONNECT method with an optional payload. If possible, could you please revert these changes, or let me know which methods, including HEAD, do not require an optional payload? Your input would be greatly appreciated. Thanks again! |
||
{ | ||
$this->makeRequest("HEAD", $uri, $params); | ||
} | ||
|
||
/** | ||
* Make TRACE request | ||
* | ||
* @param string $uri | ||
* @return void | ||
*/ | ||
public function trace(string $uri) | ||
{ | ||
$this->makeRequest("TRACE", $uri); | ||
} | ||
|
||
/** | ||
* Make CONNECT request | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
*/ | ||
public function connect(string $uri, array|string $params = []) | ||
{ | ||
$this->makeRequest("CONNECT", $uri, $params); | ||
} | ||
|
||
/** | ||
* Get response headers | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line no. 53:
I suggest you add the parameter
$curl
asnull
and useObjectManager
to initialize it. Please refer to the$this->deploymentConfig