A simple console http client, that was made during my time at the Uni
Http client is a program, which is capable of sending and recieving http-requests More on http on RFC
Python 3.7+progress
pip install -r requirements.txt
python main.py http(s)//{host} [args]
python main.py -h
- Preform a simple GET request to the address and use console as output:
python main.py https://example.com - Use file as output
python main.py https://example.com -o test.html - Send custom POST request
python main.py https://api.somethig.com -m POST -h Content-Language=ru -b login=user,password=1234
Basically sending an HTTP request and getting the HTTP response goes like that:
- Get user arguments: address, method, headers, body
- Compile a request from this arguments
- Create a python
socketfrom the request and arguments - Get the response from
socket.recv - Serve the response to the user via console or file
For every number there are a module or a class that does the work.
- Setup
argparsemodule inmain.py, I use some constants fromhelp.py. Process arguments in form ofdictinclient.py - Compile HTTP request in
request.pymodule - Use
fetch.pyto create a pythonsocket - Send python
socketto theresponse.pywhere it gets processed - Serve the respone using
io_hanlder.py
There are also:
socket_extensions.py— handles some additional methods to the socket class, they help me recieve the data:read_lineandread_sectionaddress.py— handles some logic, that is connected with http address processing