diff --git a/http.c b/http.c index 005631e..4be45d4 100644 --- a/http.c +++ b/http.c @@ -247,52 +247,52 @@ error_t fill_dirnode (struct netnode *dir) if ( go != list_of_entries ) { conn_req=(char *)malloc((strlen(dir->conn_req)+strlen(go->f_name)+1)*sizeof(char)); - sprintf(conn_req,"%s%s",dir->conn_req,go->f_name); - } - else - { - if ( dir_tok[no_of_slashes] == NULL ) - { - /* the file corresponding to base url - * user has given a file explicitly in - * the url */ - conn_req=(char *)malloc((strlen(dir->conn_req)+strlen(go->f_name)+1)*sizeof(char)); sprintf(conn_req,"%s%s",dir->conn_req,go->f_name); } - else + else { - /* the file corresponding to base url - * user has not given a file explicitly - * the url so its the index.html */ - - conn_req=(char *)malloc((strlen(dir->conn_req)+1)*sizeof(char)); - sprintf(conn_req,"%s",dir->conn_req); + if ( dir_tok[no_of_slashes] == NULL ) + { + /* the file corresponding to base url + * user has given a file explicitly in + * the url */ + conn_req=(char *)malloc((strlen(dir->conn_req)+strlen(go->f_name)+1)*sizeof(char)); + sprintf(conn_req,"%s%s",dir->conn_req,go->f_name); + } + else + { + /* the file corresponding to base url + * user has not given a file explicitly + * the url so its the index.html */ + + conn_req=(char *)malloc((strlen(dir->conn_req)+1)*sizeof(char)); + sprintf(conn_req,"%s",dir->conn_req); + } } + if( go->f_type==HTTP_DIR || go->f_type==HTTP_DIR_NOT_FILLED ) + /* the filled file is directory so it has to end + * with a / */ + strcat(conn_req,"/"); } - if( go->f_type==HTTP_DIR || go->f_type==HTTP_DIR_NOT_FILLED ) - /* the filled file is directory so it has to end - * with a / */ - strcat(conn_req,"/"); - } - comm_buf=(char *)malloc((strlen(conn_req)+20)*sizeof(char)); - sprintf(comm_buf,"GET %s HTTP/1.0",conn_req); + comm_buf=(char *)malloc((strlen(conn_req)+20)*sizeof(char)); + sprintf(comm_buf,"GET %s HTTP/1.0",conn_req); - nd = httpfs_make_node (go->f_type,url,conn_req,comm_buf,f_name); - if (!nd) - { - err = ENOMEM; - return err; - } - free(comm_buf); - free(conn_req); - free(f_name); - *prevp = nd; - nd->prevp = prevp; - prevp = &nd->next; - dir->num_ents++; - if (dir->noents) - dir->noents = FALSE; - } + nd = httpfs_make_node (go->f_type,url,conn_req,comm_buf,f_name); + if (!nd) + { + err = ENOMEM; + return err; + } + free(comm_buf); + free(conn_req); + free(f_name); + *prevp = nd; + nd->prevp = prevp; + prevp = &nd->next; + dir->num_ents++; + if (dir->noents) + dir->noents = FALSE; + } } return err; }