panda3d.core.URLSpec

from panda3d.core import URLSpec
class URLSpec

A container for a URL, e.g. “http://server:port/path”.

The URLSpec object is similar to a Filename in that it contains logic to identify the various parts of a URL and return (or modify) them separately.

Inheritance diagram

Inheritance diagram of URLSpec

__init__() → None
__init__(param0: URLSpec) → None
__init__(url: URLSpec, path: Filename) → None

Creates a URLSpec by appending a path to the end of the old URLSpec, inserting an intervening forward slash if necessary.

__init__(url: str, server_name_expected: bool) → None
assign(url: str) → URLSpec
Return type

URLSpec

property authority
Getter

Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.

Setter

Replaces the authority part of the URL specification. This includes the username, server, and port.

Return type

string

cStr() → str
compareTo(other: URLSpec) → int

Returns a number less than zero if this URLSpec sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.

empty() → bool

Returns false if the URLSpec is valid (not empty), or true if it is an empty string.

getAuthority() → str

Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.

static getDefaultPortForScheme(scheme: str) → int

Returns the default port number for the indicated scheme, or 0 if there is no known default.

getHash() → size_t
Return type

size_t

getPath() → str

Returns the path specified by the URL, or “/” if no path is specified.

getPathAndQuery() → str

Returns the path (or “/” if no path is specified), followed by the query if it is specified.

getPort() → uint16_t

Returns the port number specified by the URL, or the default port if not specified.

Return type

uint16_t

getPortStr() → str

Returns the port specified by the URL as a string, or the empty string if no port is specified. Compare this with getPort(), which returns a default port number if no port is specified.

getQuery() → str

Returns the query specified by the URL, or empty string if no query is specified.

getScheme() → str

Returns the scheme specified by the URL, or empty string if no scheme is specified.

getServer() → str

Returns the server name specified by the URL, if any. In case of an IPv6 address, does not include the enclosing brackets.

getServerAndPort() → str

Returns a string consisting of the server name, followed by a colon, followed by the port number. If the port number is not explicitly given in the URL, this string will include the implicit port number. If the server is an IPv6 address, it will be enclosed in square brackets.

getUrl() → str

Returns the complete URL specification.

getUsername() → str

Returns the username specified by the URL, if any. This might also include a password, e.g. “username:password”, although putting a password on the URL is probably a bad idea.

hasAuthority() → bool

Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise.

hasPath() → bool

Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise.

hasPort() → bool

Returns true if the URL specifies a port number, false otherwise.

hasQuery() → bool

Returns true if the URL includes a query specification, false otherwise.

hasScheme() → bool

Returns true if the URL specifies a scheme (e.g. “http:”), false otherwise.

hasServer() → bool

Returns true if the URL specifies a server name, false otherwise.

hasUsername() → bool

Returns true if the URL specifies a username (and/or password), false otherwise.

input(in: istream) → bool
isDefaultPort() → bool

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.

isSsl() → bool

Returns true if the URL’s scheme specifies an SSL-secured protocol such as https, or false otherwise.

length() → size_t
Return type

size_t

output(out: ostream) → None
property path
Getter

Returns the path specified by the URL, or “/” if no path is specified.

Setter

Replaces the path part of the URL specification.

Return type

string

property port
Getter

Returns the port number specified by the URL, or the default port if not specified.

Setter

Replaces the port part of the URL specification.

Replaces the port part of the URL specification, given a numeric port number.

Return type

uint16_t

property query
Getter

Returns the query specified by the URL, or empty string if no query is specified.

Setter

Replaces the query part of the URL specification.

Return type

string

static quote(source: str, safe: str) → str

Returns the source string with all “unsafe” characters quoted, making a string suitable for placing in a URL. Letters, digits, and the underscore, comma, period, and hyphen characters, as well as any included in the safe string, are left alone; all others are converted to hex representation.

static quotePlus(source: str, safe: str) → str

Behaves like quote() with the additional behavior of replacing spaces with plus signs.

property scheme
Getter

Returns the scheme specified by the URL, or empty string if no scheme is specified.

Setter

Replaces the scheme part of the URL specification.

Return type

string

property server
Getter

Returns the server name specified by the URL, if any. In case of an IPv6 address, does not include the enclosing brackets.

Setter

Replaces the server part of the URL specification. Unlike set_server_and_port, this method does not require IPv6 addresses to be enclosed in square brackets.

Return type

string

property server_and_port
Getter

Returns a string consisting of the server name, followed by a colon, followed by the port number. If the port number is not explicitly given in the URL, this string will include the implicit port number. If the server is an IPv6 address, it will be enclosed in square brackets.

Setter

Replaces the server and port parts of the URL specification simultaneously. The input string should be of the form “server:port”, or just “server” to make the port number implicit. Any IPv6 address must be enclosed in square brackets.

Return type

string

setAuthority(authority: str) → None

Replaces the authority part of the URL specification. This includes the username, server, and port.

setPath(path: str) → None

Replaces the path part of the URL specification.

setPort(port: str) → None

Replaces the port part of the URL specification.

setPort(port: uint16_t) → None

Replaces the port part of the URL specification, given a numeric port number.

setQuery(query: str) → None

Replaces the query part of the URL specification.

setScheme(scheme: str) → None

Replaces the scheme part of the URL specification.

setServer(server: str) → None

Replaces the server part of the URL specification. Unlike set_server_and_port, this method does not require IPv6 addresses to be enclosed in square brackets.

setServerAndPort(server_and_port: str) → None

Replaces the server and port parts of the URL specification simultaneously. The input string should be of the form “server:port”, or just “server” to make the port number implicit. Any IPv6 address must be enclosed in square brackets.

setUrl(url: str, server_name_expected: bool) → None

Completely replaces the URL with the indicated string. If server_name_expected is true, it is a hint that an undecorated URL is probably a server name, not a local filename.

setUsername(username: str) → None

Replaces the username part of the URL specification.

size() → size_t
Return type

size_t

property ssl

Returns true if the URL’s scheme specifies an SSL-secured protocol such as https, or false otherwise.

Return type

bool

static unquote(source: str) → str

Reverses the operation of quote(): converts escaped characters of the form “%xx” to their ascii equivalent.

static unquotePlus(source: str) → str

Reverses the operation of quotePlus(): converts escaped characters of the form “%xx” to their ascii equivalent, and also converts plus signs to spaces.

property username
Getter

Returns the username specified by the URL, if any. This might also include a password, e.g. “username:password”, although putting a password on the URL is probably a bad idea.

Setter

Replaces the username part of the URL specification.

Return type

string