Skip to content

Bug: CURLRequest resolving invalid headers #8299

@neznaika0

Description

@neznaika0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions