Python Network Programming
by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
How it works...
In the server script, the SecureXMLRPCServer subclass is created by inheriting from SimpleXMLRPCServer. In this subclass initialization code, we created the VerifyingRequestHandler class that actually intercepts the request and does the basic authentication using the authenticate() method.
In the authenticate() method, the HTTP request is passed as an argument. This method checks the presence of the value of authorization. If its value is set to basic, it then decodes the encoded password with the b64decode() function from the base64 standard module. After extracting the username and password, it then checks that with the server's given credentials set up initially.
In the run_server() function, a simple echo() sub function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access