Commit a56d8192 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Add Request.Scheme property. Take HTTP headers into account to detect 'https'.

[GB.WEB]
* NEW: Request.Scheme is a new property that replaces Application.Protocol.
* NEW: Request.Scheme now returns '"https"' according to the contents of the 'REQUEST_SCHEME' or 'X_FORWARDED_PROTO' headers passed to the CGI script.
parent 76e9bd56
Pipeline #337667006 passed with stage
in 24 minutes and 35 seconds
[Component]
Key=gb.web
Version=3.16.0
Version=3.16.90
Authors=Benoît Minisini
Include=gb.util.web
# Gambas Project File 3.0
Title=Web applications tools
Startup=Main
Version=3.16.0
Version=3.16.90
VersionFile=1
Component=gb.db
Component=gb.web
......
......@@ -12,7 +12,6 @@ Property Protocol As String
Private $sLogFile As String
Private $hLogFile As File
Private $sProtocol As String = "http"
Private $sRoot As String
Private Function Host_Read() As String
......@@ -69,17 +68,16 @@ End
Private Function Protocol_Read() As String
Return $sProtocol
Return Request.Scheme
End
Private Sub Protocol_Write(Value As String)
$sProtocol = Value
Request.Scheme = Value
End
Private Function Port_Read() As String
Return CGI["SERVER_PORT"]
......
......@@ -17,6 +17,7 @@ Property TempDir As String
Property MaxFileSize As Long
Property Read ContentType As String
Property Read ContentLength As Integer
Property Scheme As String
Property Read Get As _Request_Get
Property Read Post As _Request_Post
......@@ -34,6 +35,8 @@ Private $bDebug As Boolean
Private $sTempDir As String
Private $iMaxFileSize As Long = 128 * 1048576
Private $sLanguage As String
Private $sScheme As String
Private $bSchemeInit As Boolean
Private Sub Decode()
......@@ -318,3 +321,27 @@ Private Function ContentLength_Read() As Integer
Return -1
End
Private Function Scheme_Read() As String
If Not $bSchemeInit Then
If CGI["REQUEST_SCHEME"] = "https" Or If CGI["X_FORWARDED_PROTO"] = "https" Then
$sScheme = "https"
Endif
$bSchemeInit = True
Endif
If $sScheme Then Return $sScheme
Return "http"
End
Private Sub Scheme_Write(Value As String)
$sScheme = Value
$bSchemeInit = Value
End
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment