From 7e6f607b294603824a0bd251ddf2c40dbc0e3c1e Mon Sep 17 00:00:00 2001 From: Sam Habiel Date: Mon, 20 Jun 2022 16:00:13 -0400 Subject: [PATCH] Fix regression in 58a9e222df8d11a9ddac2fd161711ddc41ac8296 We checked for failure of getting a web page using $D(HTTPERR). That was not correct. HTTPERR is always defined and equal to zero in non-error cases. The correct way is to use an if statement on it. As a result, we couldn't get index.html pages anymore. And it turns out there was no explicit test for index.html pages. Now added. --- src/_webhome.m | 4 ++-- src/_webtest.m | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/_webhome.m b/src/_webhome.m index b0e360c..adbaff6 100644 --- a/src/_webhome.m +++ b/src/_webhome.m @@ -1,4 +1,4 @@ -%webhome ; VEN/SMH - Home page processor;Jun 20, 2022@14:46 +%webhome ; VEN/SMH - Home page processor;Jun 20, 2022@15:59 ;; ; Copyright 2013-2019 Sam Habiel ; Copyright 2022 YottaDB LLC @@ -22,7 +22,7 @@ N ARGS S ARGS("*")="index.html" ; Retrieve index.html from filesystem before returning default page D FILESYS^%webapi(.RESULT,.ARGS) ; If we have an error, it means we don't have an index page; ignore and return handlers page instead - I $D(HTTPERR) K HTTPERR,RESULT + I HTTPERR S HTTPERR=0 K RESULT ; If we found an index.html don't return the default I $D(RESULT) QUIT ; If we are in no global mode quit as well as the below loop won't tell us anything diff --git a/src/_webtest.m b/src/_webtest.m index bf532c2..f117cd5 100644 --- a/src/_webtest.m +++ b/src/_webtest.m @@ -1,4 +1,4 @@ -%webtest ; ose/smh - Web Services Tester;Jun 20, 2022@14:47 +%webtest ; ose/smh - Web Services Tester;Jun 20, 2022@15:59 ; Runs only on GTM/YDB ; Requires M-Unit ; @@ -346,6 +346,27 @@ set ^%webhome=oldDir quit ; +tHomePage ; @Test Getting index.html page + new oldDir set oldDir=$g(^%webhome) + set ^%webhome="/tmp/" + new random s random=$R(9817234) + open "/tmp/index.html":(newversion) + use "/tmp/index.html" + write "",! + write "",! + write "",! + write "

My First Heading

",! + write "

My first paragraph."_random_"

",! + write "",! + write "",! + close "/tmp/index.html" + n httpStatus,return + d &libcurl.curl(.httpStatus,.return,"GET","http://127.0.0.1:55728/") + d CHKEQ^%ut(httpStatus,200) + d CHKTF^%ut(return[random) + set ^%webhome=oldDir + quit + ; tINIT ; @TEST Test Fileman INIT code if $text(^DI)="" quit ; no fileman ;