Skip to content

Commit

Permalink
Fix regression in 58a9e22
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shabiel committed Jun 20, 2022
1 parent 58a9e22 commit 7e6f607
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/_webhome.m
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
23 changes: 22 additions & 1 deletion src/_webtest.m
Original file line number Diff line number Diff line change
@@ -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
;
Expand Down Expand Up @@ -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 "<!DOCTYPE html>",!
write "<html>",!
write "<body>",!
write "<h1>My First Heading</h1>",!
write "<p>My first paragraph."_random_"</p>",!
write "</body>",!
write "</html>",!
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
;
Expand Down

0 comments on commit 7e6f607

Please sign in to comment.