mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
gstatic.com doesn't want a port number
This commit is contained in:
parent
1cbec3eef0
commit
b7134366df
@ -3570,8 +3570,17 @@ make_header() {
|
|||||||
<< _client->get_http_version_string() << "\r\n";
|
<< _client->get_http_version_string() << "\r\n";
|
||||||
|
|
||||||
if (_client->get_http_version() >= HTTPEnum::HV_11) {
|
if (_client->get_http_version() >= HTTPEnum::HV_11) {
|
||||||
|
|
||||||
stream
|
stream
|
||||||
<< "Host: " << _request.get_url().get_server_and_port() << "\r\n";
|
<< "Host: " << _request.get_url().get_server();
|
||||||
|
if (!_request.get_url().is_default_port()) {
|
||||||
|
// It appears that some servers (notably gstatic.com) might
|
||||||
|
// return a 404 if you include an explicit port number in with
|
||||||
|
// the Host: header, even if it is the default port. So, don't
|
||||||
|
// include the port number unless we need to.
|
||||||
|
stream << ":" << _request.get_url().get_port();
|
||||||
|
}
|
||||||
|
stream << "\r\n";
|
||||||
if (!get_persistent_connection()) {
|
if (!get_persistent_connection()) {
|
||||||
stream
|
stream
|
||||||
<< "Connection: close\r\n";
|
<< "Connection: close\r\n";
|
||||||
|
@ -85,16 +85,44 @@ get_port() const {
|
|||||||
if (has_port()) {
|
if (has_port()) {
|
||||||
return _port;
|
return _port;
|
||||||
}
|
}
|
||||||
string scheme = get_scheme();
|
return get_default_port_for_scheme(get_scheme());
|
||||||
if (scheme == "https") {
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: URLSpec::is_default_port
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if the port number encoded in this URL
|
||||||
|
// is the default port number for the scheme (or if
|
||||||
|
// there is no port number), or false if it is a
|
||||||
|
// nonstandard port.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool URLSpec::
|
||||||
|
is_default_port() const {
|
||||||
|
if (!has_port()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (_port == get_default_port_for_scheme(get_scheme()));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: URLSpec::get_default_port_for_scheme
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns the default port number for the indicated
|
||||||
|
// scheme, or 0 if there is no known default.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int URLSpec::
|
||||||
|
get_default_port_for_scheme(const string &scheme) {
|
||||||
|
if (scheme == "http" || scheme.empty()) {
|
||||||
|
return 80;
|
||||||
|
|
||||||
|
} else if (scheme == "https") {
|
||||||
return 443;
|
return 443;
|
||||||
|
|
||||||
} else if (scheme == "socks") {
|
} else if (scheme == "socks") {
|
||||||
return 1080;
|
return 1080;
|
||||||
|
|
||||||
} else { // == "http"
|
|
||||||
return 80;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -54,6 +54,8 @@ PUBLISHED:
|
|||||||
INLINE string get_port_str() const;
|
INLINE string get_port_str() const;
|
||||||
int get_port() const;
|
int get_port() const;
|
||||||
string get_server_and_port() const;
|
string get_server_and_port() const;
|
||||||
|
bool is_default_port() const;
|
||||||
|
static int get_default_port_for_scheme(const string &scheme);
|
||||||
string get_path() const;
|
string get_path() const;
|
||||||
INLINE string get_query() const;
|
INLINE string get_query() const;
|
||||||
string get_path_and_query() const;
|
string get_path_and_query() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user