Skip to content

Update Curl to respect case-insensitive headers #29274

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

Merged
merged 12 commits into from
Sep 18, 2020

Conversation

pmzandbergen
Copy link
Contributor

@pmzandbergen pmzandbergen commented Jul 26, 2020

According to RFC 2616 header names are case-insensitive: "Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive." - see https://tools.ietf.org/html/rfc2616#section-4.2

The "Set-Cookie" comparison in the current Curl client is case-sensitive and can cause problems with some (rare) HTTP servers.

Description (*)

According to RFC 2616 header names are case-insensitive: "Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive." - see https://tools.ietf.org/html/rfc2616#section-4.2

The "Set-Cookie" comparison in the previous version is case-sensitive and can cause problems with some (rare) HTTP servers.

Related Pull Requests

None

Fixed Issues (if relevant)

Did not create an issue

Manual testing scenarios (*)

  1. Simulate a HTTP server to return a "set-cookie" or "SET-COOKIE" HTTP header
  2. Test the original client if it respects those header names (it does not)
  3. Test the new version (it does)

Questions or comments

Please note that I did not provide a unit test for this specific issue. If required please let me know.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Update Curl to respect case-insensitive headers #29524: Update Curl to respect case-insensitive headers

According to RFC 2616 header names are case-insensitive: "Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive." - see https://tools.ietf.org/html/rfc2616#section-4.2

The "Set-Cookie" comparison in the previous version is case-sensitive and can cause problems with some (rare) HTTP servers.
@m2-assistant
Copy link

m2-assistant bot commented Jul 26, 2020

Hi @pmzandbergen. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@rogyar
Copy link
Contributor

rogyar commented Jul 26, 2020

Hi @pmzandbergen.
Please, sign Adobe CLA. It's a required step for introducing your changes to Magento core. Thank you.

@pmzandbergen
Copy link
Contributor Author

Hi @pmzandbergen.
Please, sign Adobe CLA. It's a required step for introducing your changes to Magento core. Thank you.

@rogyar tried to do so yesterday but the site gave a SSL error. Seems to be fixed, checking the CLA now.

@m2-assistant
Copy link

m2-assistant bot commented Jul 27, 2020

Hi @pmzandbergen, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@pmzandbergen pmzandbergen reopened this Jul 27, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jul 27, 2020

Hi @pmzandbergen. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

@ghost ghost unassigned rogyar Jul 27, 2020
@ihor-sviziev ihor-sviziev added Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests labels Jul 29, 2020
@ihor-sviziev ihor-sviziev self-assigned this Jul 29, 2020
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good. Would be good to have strict comparison and cover your change with some kind of test, for instance unit test.
Could you update your PR accordingly?

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@pmzandbergen
Copy link
Contributor Author

In general looks good. Would be good to have strict comparison

Done

and cover your change with some kind of test, for instance unit test.

There are no existing tests for the cookie handling of the client. Adding tests for the cookie handling in general would be nice.

Could you update your PR accordingly?

Done.

@pmzandbergen
Copy link
Contributor Author

cover your change with some kind of test

I'll add tests next Friday.

@pmzandbergen pmzandbergen changed the title Update Curl to respect case-insensitive headers WIP: Update Curl to respect case-insensitive headers Jul 29, 2020
@pmzandbergen pmzandbergen changed the title WIP: Update Curl to respect case-insensitive headers Update Curl to respect case-insensitive headers Aug 2, 2020
@pmzandbergen
Copy link
Contributor Author

@ihor-sviziev added tests. Unfortunately the cUrl class needs to be extended for this test to allow mocking of the curl_exec function since it calls the protected parseHeaders method. The CurlMockTest class could be used for other tests requiring a response as well.

@ihor-sviziev ihor-sviziev removed the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Aug 2, 2020
@pmzandbergen
Copy link
Contributor Author

Hi @pmzandbergen.
Thank you for your collaboration.
Do you have some updates regarding test coverage?
If you need some help on it, please tell us.
Thank you.

Unfortunately there are only 24 hours in a day ;-) It's on my TODO list, updates will follow.

@pmzandbergen
Copy link
Contributor Author

Unfortunately tests still failing. Could you try following option?
#29274 (comment)

Tests updated, removed the Curl mock and added tests using the reflection method instead.

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@sidolov
Copy link
Contributor

sidolov commented Aug 31, 2020

Failed tests are not related to the PR changes

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-8107 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@pmzandbergen thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-8107 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Need to become a debugger to check the value on line:
 if ("Set-Cookie" == $name) {
  1. Go to Admin -> Find Partners & Extensions (for example);

Before: ✖️ It doesn't respect those header names ("set-cookie" or "SET-COOKIE")

2020-09-17_09-16

After: ✔️ It respects those header names

2020-09-17_09-21
2020-09-17_09-21_1

@m2-assistant
Copy link

m2-assistant bot commented Sep 18, 2020

Hi @pmzandbergen, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: special achievement Award: test coverage Component: HTTP Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Issue] Update Curl to respect case-insensitive headers
9 participants