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: base_uri or baseURI in curlrequest? #9265

Open
warmbook opened this issue Nov 11, 2024 · 4 comments
Open

Bug: base_uri or baseURI in curlrequest? #9265

warmbook opened this issue Nov 11, 2024 · 4 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@warmbook
Copy link

warmbook commented Nov 11, 2024

PHP Version

8.1

CodeIgniter4 Version

4.5.4

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

No response

What happened?

In the manual and CodeIgniter\HTTP\CURLRequest->parseOptions, it's 'baseURI '. But in Config\Services::curlrequest, it's 'base_uri'.

Steps to Reproduce

View the code

Expected Output

Use one of 'baseURI' and 'base_uri'.

Anything else?

No response

@warmbook warmbook added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 11, 2024
@neznaika0
Copy link
Contributor

Its not bug. See

return new CURLRequest(
    $config,
    new URI($options['base_uri'] ?? null),
    $response,
    $options
);

base_url for a service is not the same as baseUrl for a CURLRequest. base_url is here only for initial URI setup.

It looks weird, but it works

@warmbook
Copy link
Author

@neznaika0 But in the manual, it's 'baseURI ':

$client = service('curlrequest', [
'baseURI' => 'https://example.com/api/v1/',
]);

@neznaika0
Copy link
Contributor

Right.
Example, you can write to better understand the situation new URI($options['start_url'] ?? null),
At each stage, different parameters are configured. You will still get https://example.com/api/v1/

$curl = service('curlrequest', [
    'baseURI'  => 'https://example.com/api/v1/',
   'start_url' => 'https://example.com/',
]);

@michalsn
Copy link
Member

Yes, this seems like a bug created when we transited from snake_case to camelCase (a loooong time ago). It wasn't spotted, because parseOptions() method is called every time, setting the correct URI.

Feel free to send a PR with the fix.

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

3 participants