I am facing a problem whereby a file that is read is truncated while sending over a socket.
It is a simple web server that replies with a file that is stored on the flash file system, it always gets truncated at 1,072 bytes/chars.
If I print the file to the console instead, the entire file gets printed, but it refuses to send the whole file over the socket.
The full file size is 2,211 characters / bytes so this is not a huge file:
here's the method that gets are returns the file, not sure if it is sufficient ?
Code: Select all
def page(cl):
with open('/www/js/index.js', 'r') as html:
cl.send(html.read())
cl.close()
while True:
try:
cl, addr = s.accept()
print('client connected from', addr)
raw = cl.recv(1024).decode('UTF-8')
if not raw:
print('Null Request.',addr)
cl.close()
else:
print(raw)
page(cl)
except Exception as err:
print(err)