Soup.ClientContext¶
Fields¶
None
Methods¶
|
|
|
|
|
|
|
|
Details¶
- class Soup.ClientContext¶
A
Soup.ClientContext
provides additional information about the client making a particular request. In particular, you can useSoup.ClientContext.get_auth_domain
() andSoup.ClientContext.get_auth_user
() to determine if HTTP authentication was used successfully.Soup.ClientContext.get_remote_address
() and/orSoup.ClientContext.get_host
() can be used to get information for logging or debugging purposes.Soup.ClientContext.get_gsocket
() may also be of use in some situations (eg, tracking when multiple requests are made on the same connection).- get_address()¶
- Returns:
the
Soup.Address
associated with the remote end of a connection, it may beNone
if you usedSoup.Server.accept_iostream
().- Return type:
Soup.Address
orNone
Retrieves the
Soup.Address
associated with the remote end of a connection.Deprecated since version ???: Use
Soup.ClientContext.get_remote_address
(), which returns aGio.SocketAddress
.
- get_auth_domain()¶
- Returns:
a
Soup.AuthDomain
, orNone
if the request was not authenticated.- Return type:
Checks whether the request associated with self has been authenticated, and if so returns the
Soup.AuthDomain
that authenticated it.
- get_auth_user()¶
- Returns:
the authenticated-as user, or
None
if the request was not authenticated.- Return type:
Checks whether the request associated with self has been authenticated, and if so returns the username that the client authenticated as.
- get_gsocket()¶
- Returns:
the
Gio.Socket
that self is associated with,None
if you usedSoup.Server.accept_iostream
().- Return type:
Gio.Socket
orNone
Retrieves the
Gio.Socket
that self is associated with.If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (eg, by using weak references), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.
New in version 2.48.
- get_host()¶
- Returns:
the IP address associated with the remote end of a connection, it may be
None
if you usedSoup.Server.accept_iostream
().- Return type:
Retrieves the IP address associated with the remote end of a connection.
- get_local_address()¶
- Returns:
the
Gio.SocketAddress
associated with the local end of a connection, it may beNone
if you usedSoup.Server.accept_iostream
().- Return type:
Retrieves the
Gio.SocketAddress
associated with the local end of a connection.New in version 2.48.
- get_remote_address()¶
- Returns:
the
Gio.SocketAddress
associated with the remote end of a connection, it may beNone
if you usedSoup.Server.accept_iostream
().- Return type:
Retrieves the
Gio.SocketAddress
associated with the remote end of a connection.New in version 2.48.
- get_socket()¶
- Returns:
the
Soup.Socket
that self is associated with.- Return type:
Retrieves the
Soup.Socket
that self is associated with.If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (either by using weak references, or by connecting to the
Soup.Socket
::disconnected
signal), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.Deprecated since version ???: use
Soup.ClientContext.get_gsocket
(), which returns aGio.Socket
.
- steal_connection()¶
- Returns:
the
Gio.IOStream
formerly associated with self (orNone
if self was no longer associated with a connection). No guarantees are made about what kind ofGio.IOStream
is returned.- Return type:
“Steals” the HTTP connection associated with self from its
Soup.Server
. This happens immediately, regardless of the current state of the connection; if the response to the currentSoup.Message
has not yet finished being sent, then it will be discarded; you can steal the connection from aSoup.Message
:wrote-informational
orSoup.Message
:wrote-body
signal handler if you need to wait for part or all of the response to be sent.Note that when calling this function from C, self will most likely be freed as a side effect.
New in version 2.50.