I have a method that redirects to SSL or non-SSL as required. I
doubt it is
optimal, but it works.
`*********************************************************************
******
********
` use_SSL
`
` Switch to SSL if it is not SSL
`*********************************************************************
******
********
method "use_SSL" ($ssl = TRUE)
if ($ssl)
if ((get request info ("*secure")) = "0")
redirect ("https://" + replace string (get request info
("Host"); ":" + get request info ("*host port"); "") +
db_requested_url)
end if
else
if ((get request info ("*secure")) = "1")
redirect ("http://" + get request info ("Host") +
db_requested_url)
end if
end method
`*********************************************************************
******
********
` db_requested_url
`
` Return the requested url with parameters
`*********************************************************************
******
********
method "db_requested_url"
c_text ($url)
$url := get query params
if (length ($url) > 0)
$url := requested url + "?"+ $url
else
$url := requested url
end if
return ($url)
end method
A few notes about the above methods:
- 'get request info("foo")' is more concisely expressed as 'request
info{"foo"}'
- The above will fail if the original request came in on a port other
than port 80, because request info{"Host"} returns the hostname:port
for ports other than 80, then you are adding the port again. In any
case, you don't want to add the original port, because SSL goes to
port 443, not the original port.
The best way in v4 to build the url would be: "https://%s%s" %
(request info{"*host"}; full requested url)
- db_requested_url can be replaced by the v4 command 'full requested
url'.
Regards,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoylibrary.com
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/