I am trying to send an request using the below code,
import http.client
conn = http.client.HTTPConnection("localhost")
payload = "GET /_hidden/index.html HTTP/1.1\r\nHost: notlocalhost\r\n\r\n"
headers = {'Host': 'localhost','Content-Length': '56','User-Agent':'-'}
conn.request("GET", "/", payload, headers)
res = conn.getresponse()
#ress = conn.getresponse()
data = res.read()
#data2 = res.read()
print(data.decode("utf-8"))
#print(data2.decode("utf-8"))
I am expecting two responses from the server and the server is also sending 2 responses but how can I print both of them? if I have an other conn.getresponse()
I am getting an error. I have attached the server log for a reference both the request sent are accepted in the server but I want to print both the response.
You can just follow the request chain
once you understand the above code snippet. you may then include your specific needs into the code example, such as the code below in the second snippet.
call it as such
Extra
learn more about
connection.request
via the documentation