maxcutler / python-wordpress-xmlrpc

Python library for WordPress XML-RPC integration
http://python-wordpress-xmlrpc.rtfd.org
MIT License
380 stars 129 forks source link

i have problem in adding new cookies for xmlrpc.client in Python 3 #124

Open dido97 opened 5 years ago

dido97 commented 5 years ago

i tried this from https://stackoverflow.com/questions/25876503/how-to-retain-cookies-for-xmlrpc-client-in-python-3

class CookiesTransport(xmlrpc.client.Transport): """A Transport subclass that retains cookies over its lifetime."""

def __init__(self):
    super().__init__()
    self._cookies = []

def send_headers(self, connection, headers):
    if self._cookies:
        connection.putheader("Cookie", "; ".join(self._cookies))
    super().send_headers(connection, headers)

def parse_response(self, response):
    for header in response.msg.get_all("Set-Cookie"):
        cookie = header.split(";", 1)[0]
        self._cookies.append(cookie)
    return super().parse_response(response)

proxy = xmlrpc.client.ServerProxy(URL, CookiesTransport())

but not worked is there any way to add new cookie in the client request