Skip to content
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

Bug: CURLRequest resolving invalid headers #8299

Closed
neznaika0 opened this issue Dec 6, 2023 · 2 comments
Closed

Bug: CURLRequest resolving invalid headers #8299

neznaika0 opened this issue Dec 6, 2023 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@neznaika0
Copy link
Contributor

neznaika0 commented Dec 6, 2023

PHP Version

8.2

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache, cli-server

Database

No response

What happened?

Run test Controller:

<?php

namespace App\Controllers;

use Config\Services;

class Home extends BaseController
{
    public function index(): string
    {
        echo '<pre>';

        echo 'Local:' . PHP_EOL;
        var_dump(response()->headers());

        echo 'Curl:' . PHP_EOL;
        var_dump(Services::curlrequest()->get('https://ya.ru/')->headers());

        echo '</pre>';
        exit;

        // return view('welcome_message');
    }
}

See headers values, example:

// Local
  ["Content-Type"]=>
  object(CodeIgniter\HTTP\Header)#40 (2) {
    ["name":protected]=>
    string(12) "Content-Type"
    ["value":protected]=>
    string(24) "text/html; charset=UTF-8"
  }

// Curl
  ["Content-Type"]=>
  object(CodeIgniter\HTTP\Header)#90 (2) {
    ["name":protected]=>
    string(12) "Content-Type"
    ["value":protected]=>
    string(25) " text/html; charset=UTF-8"
  }

// Curl in Console tests
["Date"]=>
  object(CodeIgniter\HTTP\Header)#93 (2) {
    ["name":protected]=>
    string(4) "Date"
    ["value":protected]=>
"   string(31) " Wed, 06 Dec 2023 08:39:51 GMT
  }

Curl response contains spaces, new lines.

Should I apply trim() to all headers before installing?

Expected Output

Headers values without spaces/new lines

@neznaika0 neznaika0 added the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 6, 2023
@kenjis
Copy link
Member

kenjis commented Dec 6, 2023

Check 4.5 branch and #8240.
If you need to fix in develop, back port it.

@neznaika0
Copy link
Contributor Author

OK, I manually patched the files. For now, this is enough until the release of 4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants