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

FIX: enable stream context to pass through CWP egres proxy, fixes #156 #157

Merged
merged 1 commit into from
May 13, 2019

Conversation

smindel
Copy link

@smindel smindel commented May 12, 2019

Replacing fsockopen() with file_get_contents() enables you to set a default stream context accounting for the CWP egres proxy like this:

use SilverStripe\Core\Environment;

if(Environment::getEnv('SS_OUTBOUND_PROXY') && Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
    stream_context_set_default([
        'http' => [
            'proxy' => sprintf(
                'tcp://%s:%s',
                Environment::getEnv('SS_OUTBOUND_PROXY'),
                Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
            ),
            'request_fulluri' => true,
        ]
    ]);
}

The above code in app/_config.php sets up the egres proxy not only for this module but all outgoing connections that respect default stream contexts in your entire project.

@smindel smindel force-pushed the issue-156-utilise-stream-context branch from 1ec1283 to 5eb27ea Compare May 12, 2019 22:51
@smindel smindel force-pushed the issue-156-utilise-stream-context branch from 5eb27ea to 2caacf8 Compare May 12, 2019 23:42
@codecov-io
Copy link

Codecov Report

Merging #157 into master will increase coverage by 4.3%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #157     +/-   ##
===========================================
+ Coverage     73.14%   77.45%   +4.3%     
+ Complexity      126      124      -2     
===========================================
  Files             4        4             
  Lines           324      306     -18     
===========================================
  Hits            237      237             
+ Misses           87       69     -18
Impacted Files Coverage Δ Complexity Δ
src/GoogleSitemap.php 81.29% <0%> (+9.32%) 58 <0> (-2) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f8937d...2caacf8. Read the comment docs.

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.

None yet

4 participants