Skip to content
Snippets Groups Projects
Commit 64a7e74f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't try to send 0-byte files

Saves some opening, reading, and logging, but otherwise was harmeless.

Fix issue #422
parent 61b1ec93
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
...@@ -6171,11 +6171,12 @@ static void respond(http_session_t * session) ...@@ -6171,11 +6171,12 @@ static void respond(http_session_t * session)
send_headers(session,session->req.status,FALSE); send_headers(session,session->req.status,FALSE);
} }
} }
if(session->req.send_content) { int64_t content_length = flength(session->req.physical_path);
if(session->req.send_content && content_length > 0) {
off_t snt=0; off_t snt=0;
time_t start = time(NULL); time_t start = time(NULL);
lprintf(LOG_INFO,"%04d Sending file: %s (%"PRIdOFF" bytes)" lprintf(LOG_INFO,"%04d Sending file: %s (%"PRIdOFF" bytes)"
,session->socket, session->req.physical_path, flength(session->req.physical_path)); ,session->socket, session->req.physical_path, content_length);
snt=sock_sendfile(session,session->req.physical_path,session->req.range_start,session->req.range_end); snt=sock_sendfile(session,session->req.physical_path,session->req.range_start,session->req.range_end);
if(session->req.ld!=NULL) { if(session->req.ld!=NULL) {
if(snt<0) if(snt<0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment