I have implemented HTTP methods (GET,HEAD,POST and OPTIONS), that work fine. But unable to implement DELETE method. Here is code:
import socket
# creating socket instance
# socket.AF_INET = IPV4
# type=socket.SOCK_STREAM = TCP
s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
# target ip address and port
ip_address = '127.0.0.1'
port = 80 # Connection port
# instance requesting for connection to the specified address and port
try:
s.connect((ip_address,port))
# Send the DELETE request
request ="DELETE /fmweb/test.html HTTP/1.1\r\n"
request = request + "Accept: text/html\r\n\r\n"
response = s.send(request.encode())
response = s.recv(4096)
print(response.decode())
except:
print("Error")
finally:
s.close()
I tried with different configuration of IIS by adding DELETE verb, but failed to work
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 20 Jul 2023 15:49:47 GMT
Connection: close
Content-Length: 334
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>