add URLSpec::is_ssl

This commit is contained in:
David Rose 2003-05-07 20:09:26 +00:00
parent 4f6d41a4d2
commit 34dfb94e83
3 changed files with 28 additions and 5 deletions

View File

@ -1813,16 +1813,16 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url,
// An https-style request means we'll need to establish an SSL // An https-style request means we'll need to establish an SSL
// connection. // connection.
_want_ssl = (_request.get_url().get_scheme() == "https"); _want_ssl = _request.get_url().is_ssl();
_proxy_tunnel = false; _proxy_tunnel = false;
_proxy_serves_document = false; _proxy_serves_document = false;
if (!_proxy.empty()) { if (!_proxy.empty()) {
// If we're opening an SSL connection, or we ask for a direct // If we're opening an SSL connection, or the user has explicitly
// connection of some kind, or if we have a SOCKS-style proxy, // asked for a direct connection of some kind, or if we have a
// that demands a tunnel through the proxy to speak directly to // SOCKS-style proxy; each of these demands a tunnel through the
// the http server. // proxy to speak directly to the http server.
_proxy_tunnel = _proxy_tunnel =
(_want_ssl || _method == HTTPEnum::M_connect || _proxy.get_scheme() == "socks"); (_want_ssl || _method == HTTPEnum::M_connect || _proxy.get_scheme() == "socks");

View File

@ -227,6 +227,28 @@ get_query() const {
return _url.substr(_query_start); return _url.substr(_query_start);
} }
////////////////////////////////////////////////////////////////////
// Function: URLSpec::is_ssl
// Access: Published
// Description: Returns true if the URL's scheme specifies an
// SSL-secured protocol such as https, or false
// otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool URLSpec::
is_ssl() const {
if (has_scheme() && _scheme_end > 0) {
// If we have a scheme specification, assume it is SSL-secured if
// it ends in "s", except for the special case of "socks".
if (_url.substr(0, _scheme_end) == "socks") {
return false;
}
return (_url[_scheme_end - 1] == 's');
}
// If we have no scheme specification, it's not SSL-secured.
return false;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: URLSpec::get_url // Function: URLSpec::get_url
// Access: Published // Access: Published

View File

@ -60,6 +60,7 @@ PUBLISHED:
string get_server_and_port() const; string get_server_and_port() const;
string get_path() const; string get_path() const;
INLINE string get_query() const; INLINE string get_query() const;
INLINE bool is_ssl() const;
INLINE const string &get_url() const; INLINE const string &get_url() const;