Skip to content

Bug: [CURLRequest] Multiple HTTP 100 return by API  #8347

@PhpEssential

Description

@PhpEssential

PHP Version

8.1

CodeIgniter4 Version

4.4.2

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

apache

Database

No response

What happened?

When I call API built with a Flask server, this one return these headers:

HTTP/1.1 100 Continue

HTTP/1.1 100 Continue

HTTP/1.1 500 INTERNAL SERVER ERROR
Server: Werkzeug/2.2.3 Python/3.7.16
Date: Tue, 19 Dec 2023 21:30:20 GMT
Content-Type: application/json
Content-Length: 403
Access-Control-Allow-Origin: *
Connection: close

In this case the CURLRequest class doesn't parse correctlly the headers

Steps to Reproduce

Make POST API with Flask 2.2.5 in debug mode and call it via CURLRequest

Expected Output

In this case status code should be 500 not 100

Anything else?

Just change this:

        if (strpos($output, 'HTTP/1.1 100 Continue') === 0) {

By this:

        while (strpos($output, 'HTTP/1.1 100 Continue' . $breakString) === 0) {

at line 392

For others who have the problem, actually I overwrite the class and specially the function send in my project and instanciate it via this function in Config\Service:

    public static function curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = false) {
        if ($getShared) {
            return static::getSharedInstance('curlrequest');
        }
        
        if(empty($config)) {
            $config = config(App::class);
        }
        return new CURLRequest($config, new URI((empty($options['baseURI']) ? null : $options['baseURI'])), $response, $options);
     }

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