Python Forum
Capture Scheme ( http e https )
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capture Scheme ( http e https )
#1
I am using the socketserver as the example below to establish connections in the tcp layer and to be able to have interactions with the http data processing (status, headers, html ...), I believe that to start structuring a web server I must obtain the protocol (http , https and ports), how can I get (http and https) ?

import socketserver


class MyTCPHandler(socketserver.BaseRequestHandler):

    def handle(self):

        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).decode()
        # self.client_address tuple ( ip and port )
        self.client_address[0]
        # self.data.split, method splits a string into a list
        self.a_data = self.data.split()
        # print request headers
        print(self.a_data)

if __name__ == "__main__":
    HOST, PORT = "", 8000

    # Create the server, binding to localhost on port 9999
    with socketserver.TCPServer((HOST, PORT), MyTCPHandler) as server:

        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        server.serve_forever()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Request Headers (scheme) JohnnyCoffee 0 1,919 Mar-31-2021, 09:17 PM
Last Post: JohnnyCoffee
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,466 Jun-25-2020, 08:58 AM
Last Post: buran
  Https + REST Call + licence + gnutls imo 0 1,631 Jan-29-2019, 02:02 PM
Last Post: imo
  Spyder IDE - make variable explorer to follow the color scheme of the Editor Antonio 0 5,450 May-05-2018, 10:20 PM
Last Post: Antonio
  Color Scheme jliu0928 1 3,220 Aug-19-2017, 03:18 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020