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) ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
  Python Newbing on IDEa of HTTPs Request.get JSONnose.Picker ajaxstardust 1 1,178 Aug-28-2024, 07:17 AM
Last Post: Larz60+
  Request Headers (scheme) JohnnyCoffee 0 2,514 Mar-31-2021, 09:17 PM
Last Post: JohnnyCoffee
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 18,353 Jun-25-2020, 08:58 AM
Last Post: buran
  Https + REST Call + licence + gnutls imo 0 2,076 Jan-29-2019, 02:02 PM
Last Post: imo
  Spyder IDE - make variable explorer to follow the color scheme of the Editor Antonio 0 6,370 May-05-2018, 10:20 PM
Last Post: Antonio
  Color Scheme jliu0928 1 4,058 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