Changeset 8f70c06674bf6638d637075656f61e43ea438325

Show
Ignore:
Timestamp:
02/05/10 15:45:01 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1265384701 +0000
git-parent:

[6de8198aa4e7b27e09a9a6b83c160510c78c9cd0]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1265384701 +0000
Message:

fixes erroneous 404 for empty / zero byte files, refs #235

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_rest.c

    redbe430 r8f70c06  
    433433  } 
    434434  /* open */ 
    435   fd = open(rfile, O_RDONLY); 
    436   if(fd < 0) goto not_found; 
    437   contents = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); 
    438   close(fd); 
    439   if(contents == (void *)-1) goto not_found; 
     435  if(st.st_size > 0) { 
     436    fd = open(rfile, O_RDONLY); 
     437    if(fd < 0) goto not_found; 
     438    contents = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); 
     439    close(fd); 
     440    if(contents == (void *)-1) goto not_found; 
     441  } 
    440442  noit_http_response_ok(ctx, "text/html"); 
    441   noit_http_response_append(ctx, contents, st.st_size); 
    442   munmap(contents, st.st_size); 
     443  if(st.st_size > 0) { 
     444    noit_http_response_append(ctx, contents, st.st_size); 
     445    munmap(contents, st.st_size); 
     446  } 
    443447  noit_http_response_end(ctx); 
    444448  return 0;