Browse Source

Merge pull request #317 from xtne6f/pr

Fix unexpected 301 response
bel2125 9 years ago
parent
commit
455cc3c087
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/civetweb.c

+ 3 - 1
src/civetweb.c

@@ -10099,7 +10099,9 @@ handle_request(struct mg_connection *conn)
 		}
 
 		/* 12. Directory uris should end with a slash */
-		if (file.is_directory && ri->local_uri[uri_len - 1] != '/') {
+		uri_len = (int)strlen(ri->local_uri);
+		if (file.is_directory && uri_len > 0
+		    && ri->local_uri[uri_len - 1] != '/') {
 			gmt_time_string(date, sizeof(date), &curtime);
 			mg_printf(conn,
 			          "HTTP/1.1 301 Moved Permanently\r\n"