Commit 333ba228 authored by daspeter's avatar daspeter Committed by mikeytown2

Issue #2537950 by das-peter: Allow to define a port - and some cleanup

parent 49b51438
......@@ -15,6 +15,18 @@ function httprl_admin_settings_form() {
'#default_value' => variable_get('httprl_server_addr', FALSE),
'#description' => t('If left blank it will use the same server as the request. If set to -1 it will use the host name instead of an IP address. This controls the output of httprl_build_url_self()'),
);
$form['httprl_server_hostname'] = array(
'#type' => 'textfield',
'#title' => t('Host name of the server to send all self server requests to.'),
'#default_value' => variable_get('httprl_server_hostname', ''),
'#description' => t('If left blank it will use the same server as the request.'),
);
$form['httprl_server_port'] = array(
'#type' => 'textfield',
'#title' => t('Port of the server to send all self server requests to.'),
'#default_value' => variable_get('httprl_server_port', ''),
'#description' => t('If left blank it will use the port apprpriate for the selected schema below.'),
);
$form['httprl_server_schema'] = array(
'#type' => 'radios',
'#title' => t('Self Server Requests Schema: HTTP vs HTTPS'),
......
......@@ -10,6 +10,9 @@
*/
function httprl_uninstall() {
variable_del('httprl_server_addr');
variable_del('httprl_server_hostname');
variable_del('httprl_server_port');
variable_del('httprl_server_schema');
variable_del('httprl_background_callback');
variable_del('httprl_dns_timeout');
variable_del('httprl_connect_timeout');
......@@ -17,6 +20,7 @@ function httprl_uninstall() {
variable_del('httprl_timeout');
variable_del('httprl_global_timeout');
variable_del('httprl_url_inbound_alter');
variable_del('httprl_non_blocking_fclose_delay');
}
/**
......
......@@ -142,6 +142,11 @@ define('HTTPRL_SERVER_SCHEMA', 0);
*/
define('HTTPRL_NON_BLOCKING_FCLOSE_DELAY', 0);
/**
* Default port value; blank, so do not set one.
*/
define('HTTPRL_SERVER_PORT', '');
/**
* Implements hook_url_inbound_alter().
*/
......@@ -372,13 +377,17 @@ function _httprl_build_drupal_root($level = 0, $hostname_mode = 0) {
}
// Port.
$port = '';
// if ( isset($_SERVER['SERVER_PORT'])
// && is_numeric($_SERVER['SERVER_PORT'])
// && ($_SERVER['SERVER_PORT'] != 80 || $_SERVER['SERVER_PORT'] != 443)
// ) {
// $port = ':' . $_SERVER['SERVER_PORT'];
// }
$port = httprl_variable_get('httprl_server_port', HTTPRL_SERVER_PORT);
// Add the port separator if necessary.
if (!empty($port)) {
$port = ':' . $port;
}
elseif ( isset($_SERVER['SERVER_PORT'])
&& is_numeric($_SERVER['SERVER_PORT'])
&& ($_SERVER['SERVER_PORT'] != 80 || $_SERVER['SERVER_PORT'] != 443)
) {
$port = ':' . $_SERVER['SERVER_PORT'];
}
// URL schema http or https.
$schema_var = httprl_variable_get('httprl_server_schema', HTTPRL_SERVER_SCHEMA);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment