From 65288779f196b6b192ad1efe86538cfdbd5970be Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:43:39 +0000 Subject: [PATCH 1/3] Initial plan From deaf30bd37ed27b4624aa57887a708e5de6efe8f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:53:30 +0000 Subject: [PATCH 2/3] Clear CURLOPT_CUSTOMREQUEST in get() and post() methods to fix persistence issue Co-authored-by: nadar <3417221+nadar@users.noreply.github.com> --- src/Curl/Curl.php | 4 +- tests/SequentialRequestsTest.php | 99 ++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 tests/SequentialRequestsTest.php diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 5794b9f..b95e3ae 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -295,7 +295,7 @@ protected function setHttpAuth($httpauth) */ public function get($url, $data = array()) { - $this->setOpt(CURLOPT_CUSTOMREQUEST, "GET"); + $this->setOpt(CURLOPT_CUSTOMREQUEST, null); if (count($data) > 0) { $this->setOpt(CURLOPT_URL, $url.'?'.http_build_query($data)); } else { @@ -338,7 +338,7 @@ public function purge($url, $hostName = null) */ public function post($url, $data = array(), $asJson = false) { - $this->setOpt(CURLOPT_CUSTOMREQUEST, "POST"); + $this->setOpt(CURLOPT_CUSTOMREQUEST, null); $this->setOpt(CURLOPT_URL, $url); if ($asJson) { $this->prepareJsonPayload($data); diff --git a/tests/SequentialRequestsTest.php b/tests/SequentialRequestsTest.php new file mode 100644 index 0000000..4dd9c2a --- /dev/null +++ b/tests/SequentialRequestsTest.php @@ -0,0 +1,99 @@ +curl = new Curl(); + $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); + $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); + } + + /** + * Test that GET works correctly after a PUT request + */ + public function testGetAfterPut() + { + // First, make a PUT request with payload + $this->curl->put(self::TEST_URL . '/server.php', ['test' => 'put', 'key' => 'test'], true); + $this->assertTrue($this->curl->isSuccess(), 'PUT request should succeed'); + + // Then, make a GET request + $this->curl->get(self::TEST_URL . '/server.php', ['test' => 'server', 'key' => 'REQUEST_METHOD']); + $this->assertTrue($this->curl->isSuccess(), 'GET request after PUT should succeed'); + $this->assertEquals('GET', $this->curl->response, 'Request method should be GET, not PUT'); + } + + /** + * Test that GET works correctly after a DELETE request + */ + public function testGetAfterDelete() + { + // First, make a DELETE request with payload + $this->curl->delete(self::TEST_URL . '/server.php', ['test' => 'delete', 'key' => 'test'], true); + $this->assertTrue($this->curl->isSuccess(), 'DELETE request should succeed'); + + // Then, make a GET request + $this->curl->get(self::TEST_URL . '/server.php', ['test' => 'server', 'key' => 'REQUEST_METHOD']); + $this->assertTrue($this->curl->isSuccess(), 'GET request after DELETE should succeed'); + $this->assertEquals('GET', $this->curl->response, 'Request method should be GET, not DELETE'); + } + + /** + * Test that GET works correctly after a PATCH request + */ + public function testGetAfterPatch() + { + // First, make a PATCH request with payload + $this->curl->patch(self::TEST_URL . '/server.php', ['test' => 'patch', 'key' => 'test'], true); + $this->assertTrue($this->curl->isSuccess(), 'PATCH request should succeed'); + + // Then, make a GET request + $this->curl->get(self::TEST_URL . '/server.php', ['test' => 'server', 'key' => 'REQUEST_METHOD']); + $this->assertTrue($this->curl->isSuccess(), 'GET request after PATCH should succeed'); + $this->assertEquals('GET', $this->curl->response, 'Request method should be GET, not PATCH'); + } + + /** + * Test that POST works correctly after a PUT request + */ + public function testPostAfterPut() + { + // First, make a PUT request with payload + $this->curl->put(self::TEST_URL . '/server.php', ['test' => 'put', 'key' => 'test'], true); + $this->assertTrue($this->curl->isSuccess(), 'PUT request should succeed'); + + // Then, make a POST request + $this->curl->post(self::TEST_URL . '/server.php', ['test' => 'server', 'key' => 'REQUEST_METHOD']); + $this->assertTrue($this->curl->isSuccess(), 'POST request after PUT should succeed'); + $this->assertEquals('POST', $this->curl->response, 'Request method should be POST, not PUT'); + } + + public function tear_down() + { + if ($this->curl) { + $this->curl->close(); + } + parent::tear_down(); + } +} From 2121f605746dd64cf8e38557521390fee416764f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:55:18 +0000 Subject: [PATCH 3/3] Also clear CURLOPT_POSTFIELDS in get() method for complete cleanup Co-authored-by: nadar <3417221+nadar@users.noreply.github.com> --- src/Curl/Curl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index b95e3ae..0cbd5d2 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -296,6 +296,7 @@ protected function setHttpAuth($httpauth) public function get($url, $data = array()) { $this->setOpt(CURLOPT_CUSTOMREQUEST, null); + $this->setOpt(CURLOPT_POSTFIELDS, null); if (count($data) > 0) { $this->setOpt(CURLOPT_URL, $url.'?'.http_build_query($data)); } else {