From 846a5a273275a4b7c9df066fcc1317418e283ec8 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Thu, 12 Oct 2017 11:38:57 +0200 Subject: add test for correct handling of Location for 201 created http result --- tests/it_url.t | 10 ++++++++++ tests/it_url.testserver.php | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/tests/it_url.t b/tests/it_url.t index d2fbae0..9a4594e 100755 --- a/tests/it_url.t +++ b/tests/it_url.t @@ -3,6 +3,8 @@ # Tests for url.class, currently only constructor's parser +it::getopt("Usage: it_url.t [OPTIONS]"); + # Create object and parse url $url = new it_url('HTTP://falcon:joshua@www.Relog.CH:80/default.asp'); @@ -219,6 +221,14 @@ handle_server( ) ); +handle_server( + is( + it_url::get('http://localhost:8000/created_redirect'), + "Testserver output *before* created redirect", + 'it_url::get() does not follow Location of 201 (Created) result' + ) +); + $output = handle_server( ok( !it_url::get(U('http://localhost:8000/redirect_loop', array('num' => 10))), diff --git a/tests/it_url.testserver.php b/tests/it_url.testserver.php index 0fb3252..d394b58 100644 --- a/tests/it_url.testserver.php +++ b/tests/it_url.testserver.php @@ -17,6 +17,11 @@ switch ($_SERVER['PHP_SELF']) it_url::redirect(U("redirect_target", array('type' => 'permanent')), 'permanent'); break; + case "/created_redirect": + header('Location: ' . it_url::absolute(U('redirect_target', array('type' => 'created'))), true, 201); + echo "Testserver output *before* created redirect"; + exit; + case "/redirect_loop": if ($_REQUEST['num'] > 0) it_url::redirect(U("redirect_loop", array('num' => $_REQUEST['num'] - 1))); -- cgit v1.2.3