GUPnP.Context¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c |
Access control list |
||
r/w/c |
Default language |
||
r |
|
||
r |
|
||
r/w/co |
Subscription timeout |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class GUPnP.Context(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Context object wrapping shared networking bits.
GUPnP.Context
wraps the networking bits that are used by the various GUPnP classes. It automatically starts a web server on demand.For debugging, it is possible to see the messages being sent and received by setting the environment variable
GUPNP_DEBUG
.- classmethod new(iface, port)¶
- Parameters:
- Raises:
- Returns:
A new
GUPnP.Context
object, orNone
on an error- Return type:
Create a new
GUPnP.Context
with the specified iface and port.Deprecated since version 1.6.: Use [ctor`GUPnP`.Context.new_for_address] instead
- classmethod new_for_address(addr, port, uda_version)¶
- Parameters:
addr (
Gio.InetAddress
orNone
) – an IP address orNone
for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.port (
int
) – The network port to use for M-SEARCH requests or 0 for random.uda_version (
GSSDP.UDAVersion
) – The UDA version this client will adhere to
- Raises:
- Returns:
A new
GSSDP.Client
object orNone
on error.- Return type:
Creates a GUPnP context with address addr. If none is specified, GUPnP will chose the address it deems most suitable.
New in version 1.6..
- classmethod new_full(iface, addr, port, uda_version)¶
- Parameters:
addr (
Gio.InetAddress
orNone
) – an IP address orNone
for auto-detection. If you do not care about the address, but want to specify an address family, use [ctor`Glib`.InetAddress.new_any] with the appropriate family instead.port (
int
) – The network port to use for M-SEARCH requests or 0 for random.uda_version (
GSSDP.UDAVersion
) – The UDA version this client will adhere to
- Raises:
- Returns:
A new
GSSDP.Client
object orNone
on error.- Return type:
Creates a GUPnP context with address addr on network interface iface. If neither is specified, GUPnP will chose the address it deems most suitable.
New in version 1.6..
- add_server_handler(use_acl, path, callback, *user_data)¶
- Parameters:
use_acl (
bool
) –True
, if the path should query theGUPnP.Context
::acl
before serving the resource,False
otherwise.path (
str
) – the toplevel path for the handler.callback (
Soup.ServerCallback
) – callback to invoke for requests under pathuser_data (
object
orNone
) – the user_data passed to callback
Add a
Soup.ServerCallback
to theGUPnP.Context
‘sSoup.Server
.New in version 0.20.11.
- get_acl()¶
- Returns:
The access control list associated with this context or
None
if no acl is set.- Return type:
Access the
GUPnP.Acl
associated with this client. If there isn’t any, retturnsNone
. The returned ACL must not be freed.New in version 0.20.11.
- get_default_language()¶
- Returns:
The default content of the Content-Language header.
- Return type:
Get the default Content-Language header for this context.
New in version 0.18.0.
- get_port()¶
- Returns:
The port the SOAP server is running on.
- Return type:
Get the port that the SOAP server is running on.
- get_server()¶
- Returns:
The
Soup.Server
used by GUPnP. Do not unref this when finished.- Return type:
Get the
Soup.Server
HTTP server that GUPnP is using.
- get_session()¶
- Returns:
The
Soup.Session
used by GUPnP. Do not unref this when finished.- Return type:
Get the
Soup.Session
object that GUPnP is using.New in version 0.12.3.
- get_subscription_timeout()¶
- Returns:
The event subscription timeout in seconds.
- Return type:
Get the event subscription timeout (in seconds), or 0 meaning there is no timeout.
- host_path(local_path, server_path)¶
- Parameters:
Start hosting local_path at server_path. Files with the path local_path.LOCALE (if they exist) will be served up when LOCALE is specified in the request’s Accept-Language header.
- host_path_for_agent(local_path, server_path, user_agent)¶
- Parameters:
local_path (
str
) – Path to the local file or folder to be hostedserver_path (
str
) – Web server path already being hosteduser_agent (
GLib.Regex
) – The user-agent as aGLib.Regex
.
- Returns:
- Return type:
Use this method to serve different local path to specific user-agent(s). The path server_path must already be hosted by self.
New in version 0.14.0.
- remove_server_handler(path)¶
- Parameters:
path (
str
) – the toplevel path for the handler.
Remove a
Soup.ServerCallback
from theGUPnP.Context
‘sSoup.Server
.New in version 0.20.11.
- rewrite_uri(uri)¶
- Parameters:
uri (
str
) – an uri to rewrite if necessary- Returns:
A re-written version of the uri if the context is on a link-local IPv6 address, a copy of the uri otherwise or
None
if uri was invalid- Return type:
Utility function to re-write an uri to the IPv6 link-local form which has the zone index appended to the IP address.
New in version 1.2.0.
- set_acl(acl)¶
- Parameters:
acl (
GUPnP.Acl
orNone
) – The new access control list orNone
to remove the current list.
Attach or remove the assoicated access control list to this context. If acl is
None
, the current access control list will be removed.New in version 0.20.11.
- set_default_language(language)¶
- Parameters:
language (
str
) – A language tag as defined in RFC 2616 3.10
Set the default language for the Content-Language header to language.
If the client sends an Accept-Language header the UPnP HTTP server is required to send a Content-Language header in return. If there are no files hosted in languages which match the requested ones the Content-Language header is set to this value. The default value is “en”.
New in version 0.18.0.
Property Details¶
- GUPnP.Context.props.acl¶
-
An access control list.
New in version 0.20.11.
- GUPnP.Context.props.default_language¶
-
The content of the Content-Language header id the client sends Accept-Language and no language-specific pages to serve exist. The property defaults to ‘en’.
New in version 0.18.0.
- GUPnP.Context.props.server¶
- Name:
server
- Type:
- Default Value:
- Flags:
The
Soup.Server
HTTP server used by GUPnP.
- GUPnP.Context.props.session¶
- Name:
session
- Type:
- Default Value:
- Flags:
The
Soup.Session
object used by GUPnP.
- GUPnP.Context.props.subscription_timeout¶
- Name:
subscription-timeout
- Type:
- Default Value:
1800
- Flags:
The preferred subscription timeout: the number of seconds after which subscriptions are renewed. Set to ‘0’ if subscriptions are never to time out.