MCPcopy Create free account
hub / github.com/cztomczak/cefpython / RequestHandler

Class RequestHandler

examples/snippets/network_cookies.py:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class RequestHandler(object):
21 def __init__(self):
22 self.getcount = 0
23 self.setcount = 0
24
25 def CanGetCookies(self, frame, request, **_):
26 # There are multiple iframes on that website, let's log
27 # cookies only for the main frame.
28 if frame.IsMain():
29 self.getcount += 1
30 print("-- CanGetCookies #"+str(self.getcount))
31 print("url="+request.GetUrl()[0:80])
32 print("")
33 # Return True to allow reading cookies or False to block
34 return True
35
36 def CanSetCookie(self, frame, request, cookie, **_):
37 # There are multiple iframes on that website, let's log
38 # cookies only for the main frame.
39 if frame.IsMain():
40 self.setcount += 1
41 print("-- CanSetCookie @"+str(self.setcount))
42 print("url="+request.GetUrl()[0:80])
43 print("Name="+cookie.GetName())
44 print("Value="+cookie.GetValue())
45 print("")
46 # Return True to allow setting cookie or False to block
47 return True
48
49
50if __name__ == '__main__':

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected