HTTP clients, especially when sharing a link to a messaging applications, can automatically issue a HEAD request to sniff the kind of file.
Plan could be:
- to clean up the code to split in different methods the code to handle upload and the code to handle files serving
- to split those new functions into sending headers, sending body
- to add 2x2 new functions to handle HEAD and GET requests for download, then for upload