]> Kevux Git Server - koopa/commitdiff
Bugfix: http request uri and http response location fixes
authorKevin Day <thekevinday@gmail.com>
Wed, 26 Apr 2017 16:10:41 +0000 (11:10 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 26 Apr 2017 16:10:41 +0000 (11:10 -0500)
The request uri should include the scheme and authority where possible.
Fix a syntax error containing '$$' instead of '$'.

The response location needs to fully support an array.

common/base/classes/base_http.php
program/reservation/reservation_redirects.php

index a510ef5efd7845f842715d1ca555118a5494500f..f868a74582c566ea8872c174eea82e37777b593a 100644 (file)
@@ -2547,7 +2547,7 @@ class c_base_http extends c_base_rfc_string {
       $uri_string = $uri;
     }
 
-    $text = $this->pr_rfc_string_prepare($$uri_string);
+    $text = $this->pr_rfc_string_prepare($uri_string);
     if ($text['invalid']) {
       unset($text);
 
@@ -4118,7 +4118,7 @@ class c_base_http extends c_base_rfc_string {
       return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
     }
 
-    return c_base_return_string::s_new($this->response[self::RESPONSE_LOCATION]);
+    return c_base_return_array::s_new($this->response[self::RESPONSE_LOCATION]);
   }
 
   /**
@@ -6486,7 +6486,21 @@ class c_base_http extends c_base_rfc_string {
       return;
     }
 
-    $text = $this->pr_rfc_string_prepare($this->headers['uri']);
+    // attempt to reconstruct the uri as a full url, if possible.
+    $uri = $this->headers['uri'];
+
+    if (isset($_SERVER['SERVER_NAME']) && is_string($_SERVER['SERVER_NAME']) && mb_strlen($_SERVER['SERVER_NAME']) > 0) {
+      if (isset($_SERVER['HTTPS'])) {
+        $uri = 'https://' . $_SERVER['SERVER_NAME'] . $uri;
+      }
+      else {
+        $uri = 'http://' . $_SERVER['SERVER_NAME'] . $uri;
+      }
+    }
+
+    $text = $this->pr_rfc_string_prepare($uri);
+    unset($uri);
+
     if ($text['invalid']) {
       $this->request[self::REQUEST_URI]['invalid'] = TRUE;
       unset($text);
index 00a366aa85d7831ad200ae0bdd09aeefaffbb30b..25c912e9aef89d56d5a987877fe8a8cb69517755 100644 (file)
@@ -53,7 +53,7 @@ final class c_reservation_path_redirect extends c_base_path {
     // @todo: store all errors on return.
     $errors = array();
 
-    if (is_string($field_destination)) {
+    if (is_string($field_destination) || is_array($field_destination)) {
       $path->set_field_destination($field_destination);
     }