laminas / laminas-http

Provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
https://docs.laminas.dev/laminas-http/
BSD 3-Clause "New" or "Revised" License
36 stars 27 forks source link

PHP Fatal error: Uncaught Error: Call to undefined method Laminas\Http\Header\SetCookie::__toString() #81

Open kjdfjhdjkh opened 8 months ago

kjdfjhdjkh commented 8 months ago

Bug Report

Q A
Version(s) 2.19.0

Summary

When attempting to serialize the cookies using the documentation on the /laminas-http/client/cookies/#serializing-and-caching-cookies page, I get the following error:

PHP Fatal error: Uncaught Error: Call to undefined method Laminas\Http\Header\SetCookie::__toString()

on Line 270 of /laminas/laminas-http/src/Cookies.php

How to reproduce

Code:

$client = new Client();
$headers = $client->getRequest()->getHeaders();
$cookies = new Laminas\Http\Cookies($headers);

$client->setUri(_redacted_);
$client->setParameterPost(['login' => '_redacted_', 'pwd' => '_redacted_']);
$client->setMethod('POST');

$response = $client->getResponse();
$cookies->addCookiesFromResponse($response, $client->getUri());
$cookiesToCache = $cookies->getAllCookies($cookies::COOKIE_STRING_CONCAT);

Expected behavior

The $cookiesToCache variable should have the serialized string.

laminas-bot commented 8 months ago

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

You can continue using laminas/laminas-http safely. Its successor will be PSR-7 in a later revision of laminas/laminas-mvc.

Xerkus commented 8 months ago

This bug was never discovered and this apparently never worked since call to __toString() present since 2.0.0 and header never had __toString() in stable releases.

@kjdfjhdjkh I would recommend to utilize PSR-18 http client instead of this library.