Ok so my problem was fixed by asking my tcp socket to continue receiving the request data until the body is equal to the content length:
headers, body = request_data.split("\r\n\r\n", 1) # Split request data into headers and body
# get the content length from the headers
content_length = 0
for line in headers.split("\r\n"):
if "Content-Length" in line:
content_length = int(line.split(": ")[1])
break
while len(body) < content_length:
body += conn.recv(1024).decode('UTF-8')
Basically what this means if you are not using a tcp socket and still wondering why this is happening:
Your web server did NOT receive the full request YET, safari sends it on chunks for some reason, hope this helps, keep receiving the request until the body of the POST is received.