Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.64 KB | None | 0 0
  1. :) server.c exists
  2. :) server compiles
  3. :( Requesting cat.jpg returns 200, image/jpeg, and correct image
  4. :) Requesting cat.html returns 200, text/html, and correct file
  5.         :( Requesting cat2.HTML returns 200, text/html, and correct file
  6.         :( Requesting cat3.HtMl returns 200, text/html, and correct file
  7.         :( Requesting cat.gif returns 200, image/gif, and correct file
  8. :) Requesting favicon.ico returns 200, image/x-icon, and correct file
  9. :) Requesting test.css returns 200, text/css, and correct file
  10. :) Requesting test.js returns 200, text/javascript, and correct file
  11. :) Requesting hello.php returns 200, text/html, and correct output
  12.         :( Requesting hello.php? returns 200, text/html, and correct output
  13.             \ expected output, not an exit code of 0
  14.         :( Requesting hello.php?name=Alice returns 200, text/html, and correct output
  15.             \ expected output, not an exit code of 0
  16. :) Requesting /test redirects to /test/
  17.         :( Requesting /test/ outputs /test/index.html
  18.         :( Requesting directory containing index.php outputs index.php
  19.             \ expected output, not an exit code of 0
  20.         :( Requesting two files in a row (cat.html then cat.jpg) succeeds
  21.  
  22.  
  23.  
  24. bool load(FILE* file, BYTE** content, size_t* length)
  25. {
  26.    
  27.     if (file == NULL)
  28.     {
  29.         return false;
  30.     }
  31.     char* buffer = malloc(sizeof(char));
  32.  
  33.     *length = 1;
  34.     int count = 0;
  35.    
  36.     for (char read = fgetc(file); read != EOF; read = fgetc(file))
  37.     {
  38.         buffer[count] = read;    
  39.         count++;
  40.         buffer = realloc(buffer, sizeof(char) * (count + 1));
  41.     }
  42.  
  43.     *length = count;
  44.     *content = &buffer[0];
  45.  
  46.   //  free(buffer);
  47.     return true;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement