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: CURL call returns always code 200 in case de server uses HTTP/2 #3586

Closed
JanZelenka opened this issue Sep 2, 2020 · 4 comments · Fixed by #3598
Closed

Bug: CURL call returns always code 200 in case de server uses HTTP/2 #3586

JanZelenka opened this issue Sep 2, 2020 · 4 comments · Fixed by #3598
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@JanZelenka
Copy link

JanZelenka commented Sep 2, 2020

When making a curl call using the CURLRequest class and the server is IIS using the HTTP 2.0 protocol, the first header starts with "HTTP/2 "
The file CURLRequest.php contains this regex parsing on line 598:
preg_match('#^HTTP\/([12]\.[01]) ([0-9]+) (.+)#', $header, $matches);

This fails to parse. It would work if the server used HTTP/2.0 but unfortunately, IIS says HTTP/2.
As a result, no status code is retrieved and CodeIgniter probably somewhere down the way decides it's 200.

CodeIgniter 4 version: 4.0.4
Affected module(s): CURLRequest
*Context: * IIS

@JanZelenka JanZelenka added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 2, 2020
@JanZelenka
Copy link
Author

JanZelenka commented Sep 2, 2020

I did have a look at this and did some testing. This what I believe is the correct regex expression:
#^HTTP\/([12](?:\.[01])?) ([0-9]+) (.+)#

@MGatner
Copy link
Member

MGatner commented Sep 3, 2020

Thanks! Would you submit a Pull Request with your update regex?

@JanZelenka
Copy link
Author

I will try. Right now I'm quite under pressure from the actual commercial project and when I look at the process of correctly submitting a pull request, it takes more time than I have with the required test cases and so...

@MGatner
Copy link
Member

MGatner commented Sep 3, 2020

I totally get it. Do what you can. I think in this case you could probably just edit the files right in GitHub: submit the updated regex and then add to https://github.com/codeigniter4/CodeIgniter4/blob/develop/tests/system/HTTP/CURLRequestTest.php a copy of testResponseHeaders() with the shortened header.

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

Successfully merging a pull request may close this issue.

2 participants