Skip to content

Commit cdb1eb4

Browse files
committed
fix: ensure proper handling of 403 Forbidden response with appropriate headers
1 parent c0e9a35 commit cdb1eb4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Project/Sources/Methods/_onWebConnection.4dm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ End if
1414
If ($URL=$redirectURI)
1515

1616
var $options : Object:={redirectURI: $redirectURI; state: $state}
17-
17+
1818
ARRAY TEXT($names; 0)
1919
ARRAY TEXT($values; 0)
2020
WEB GET VARIABLES($names; $values)
@@ -37,6 +37,15 @@ If ($URL=$redirectURI)
3737
var $contentType : Text:="Content-Type: text/html"
3838
WEB SET HTTP HEADER($contentType)
3939
WEB SEND RAW DATA($responseBody)
40+
Else
41+
42+
// Send a 403 status line
43+
// This is not strictly necessary, but it makes it clear that the request was forbidden
44+
// and not just a 404 Not Found
45+
var $statusLine : Text:="X-STATUS: 403 Forbidden"
46+
WEB SET HTTP HEADER($statusLine)
47+
var $errorBody : Text:="<html><body><h1>403 Forbidden</h1><p>Access denied</p></body></html>"
48+
WEB SEND TEXT($errorBody; "text/html")
4049
End if
4150

4251
End if

0 commit comments

Comments
 (0)