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

Improve CURLOPT_HTTPHEADER Setting Assignment #215

Merged

Conversation

amrita-shrestha
Copy link
Contributor

This PR code prevents potential issues that could arise from setting CURLOPT_HTTPHEADER with an empty value. By adding a conditional check, we ensure that we only assign meaningful and valid header values.

        $settings[CURLOPT_HTTPHEADER] = $nHeaders;
        if (!empty($nHeaders)) {
            $settings[CURLOPT_HTTPHEADER] = $nHeaders;
        }

Testing:

  • Ensure that when $nHeaders contains valid header values, they are assigned to $settings[CURLOPT_HTTPHEADER].
  • When $nHeaders is empty, $settings[CURLOPT_HTTPHEADER] should not be set or altered.

@amrita-shrestha amrita-shrestha marked this pull request as ready for review August 17, 2023 08:28
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #215 (39bb6b0) into master (591a497) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master     #215   +/-   ##
=========================================
  Coverage     94.21%   94.21%           
- Complexity      260      261    +1     
=========================================
  Files            15       15           
  Lines           881      882    +1     
=========================================
+ Hits            830      831    +1     
  Misses           51       51           
Files Changed Coverage Δ
lib/Client.php 84.23% <100.00%> (+0.07%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@phil-davis
Copy link
Contributor

@amrita-shrestha php-cs-fixer wants a code-format change:
https://github.com/sabre-io/http/actions/runs/5888579964/job/15970228283?pr=215

You can locally do:
composer cs-fixer
Then commit and push.

.gitignore Outdated Show resolved Hide resolved
@phil-davis phil-davis self-requested a review August 17, 2023 08:38
tests/HTTP/ClientTest.php Outdated Show resolved Hide resolved
@amrita-shrestha amrita-shrestha force-pushed the remove-header-overwrite-with-null branch 2 times, most recently from a622479 to 3caa370 Compare August 17, 2023 09:13
lib/Client.php Outdated Show resolved Hide resolved
@phil-davis phil-davis requested a review from staabm August 17, 2023 10:43
@phil-davis phil-davis merged commit 6a88b28 into sabre-io:master Aug 17, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants