I’m stuck on .
404 reponse for other stages work for this stage it fails:
Here are my logs:
remote: [your_program] file not found
remote: [your_program] b'HTTP/1.1 404 Not Found\r\n\r\n'
remote: [stage-7] Failed to dump response: 'context deadline exceeded (Client.Timeout or context cancellation while reading body)'
And here’s a snippet of my code:
NOT_FOUND_404 = 'HTTP/1.1 404 Not Found'
CLRF = '\r\n'
def get_file_content(path, directory):
if not directory:
directory = ''
filename = path[7:]
print(directory, filename)
f_path = os.path.join(directory, filename)
if not filename or not os.path.exists(f_path):
print('file not found')
response = (NOT_FOUND_404 + CRLF + CRLF).encode('ASCII')
else:
print('file found', directory, filename)
with open(f_path, 'rb') as f:
content = f.read()
print(content)
res_arr = [OK_402, 'Content-Type: application/octet-stream', 'Content-Length: ' + str(len(content))]
response = (CLRF.join(res_arr) + CLRF + CLRF).encode('ASCII') + content
print(response)
return response