def wrapper(client, method, url, body=None, headers=None): cookiejar = LWPCookieJar() cookiejar._really_load( StringIO("#LWP-Cookies-2.0\n" + client.credential.get(field,'')), "cookies.txt",True,True) req = Request(url, body, headers or {}, method=method) cookiejar.clear_expired_cookies() cookiejar.add_cookie_header(req) status, headers, body = request(client,req.method,req.full_url,req.data,dict(req.header_items())) response = addinfourl(None, headers, req.full_url, status) cookiejar.extract_cookies(response,req) client.credential[field] = cookiejar.as_lwp_str() return (status, headers, body)
def wrapper(client, method, url, body=None, headers=None): cookiejar = LWPCookieJar() cookiejar._really_load( StringIO("#LWP-Cookies-2.0\n" + client.credential.get(field, '')), "cookies.txt", True, True) req = Request(url, body, headers or {}, method=method) cookiejar.clear_expired_cookies() cookiejar.add_cookie_header(req) status, headers, body = request(client, req.method, req.full_url, req.data, dict(req.header_items())) response = addinfourl(None, headers, req.full_url, status) cookiejar.extract_cookies(response, req) client.credential[field] = cookiejar.as_lwp_str() return (status, headers, body)