Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions features/class-wp-cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ Feature: Various utilities for WP-CLI commands
| func |
| proc_open |
| proc_close |

Scenario: HTTP URL scheme does not set HTTPS server variable
Given an empty directory

When I run `wp --skip-wordpress eval 'WP_CLI::set_url("http://example.com"); echo isset($_SERVER["HTTPS"]) ? "set" : "not set";'`
Then STDOUT should be:
"""
not set
"""

Scenario: HTTPS URL scheme sets HTTPS server variable
Given an empty directory

When I run `wp --skip-wordpress eval 'WP_CLI::set_url("https://example.com"); echo isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on" ? "on" : "off";'`
Then STDOUT should be:
"""
on
"""
Comment thread
swissspidy marked this conversation as resolved.
Outdated
2 changes: 2 additions & 0 deletions php/class-wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ private static function set_url_params( $url_parts ) {
if ( isset( $url_parts['host'] ) ) {
if ( isset( $url_parts['scheme'] ) && 'https' === strtolower( $url_parts['scheme'] ) ) {
$_SERVER['HTTPS'] = 'on';
} else {
unset( $_SERVER['HTTPS'] );
}

$_SERVER['HTTP_HOST'] = $url_parts['host'];
Expand Down
Loading