codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.4k stars 1.9k forks source link

Bug: CURLRequest ->getHeaderLine('Location') returns old data. #7421

Closed gixxy22 closed 1 year ago

gixxy22 commented 1 year ago

PHP Version

8.1

CodeIgniter4 Version

4.3.2

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

MariaDB 10.2

What happened?

When using $curlrequest() and getHeaderLine('Location') in a foreach loop, if a response header is redirected and has a Location, it is returned in the response, however on the next item in the loop the previous Location is still set even though it it is not a redirect or have a Location set.

It seems as though the HeaderLines are not getting unset on each request.

Steps to Reproduce

Create an array of a URLs, with the first being a redirected URL. Create a foreach loop to grab the Location Header for each URL. If the second item in the array does not have a Location header, the previous items Location Header is used.

Expected Output

If no Location Header is present for the current item, return null or an empty value.

Anything else?

No response

kenjis commented 1 year ago

Duplicate of #7394

Fixed by #7398

kenjis commented 1 year ago

Before you begin, please ensure that there are no existing issues, whether still open or closed, related to your report. If there is, your report will be closed promptly.

For example, you can search the GitHub repository with the keyword "CURLRequest".