0

If my request line is- GET /hello.php?name=mike HTTP/1.1 What should be stored in abs_path and query fields? and if my request line is- GET /hello.html HTTP/1.1 then what should be stored in abs_path and query fields?

0

For: GET /hello.php?name=mike HTTP/1.1

abs_path: /hello.php

query: name=mike


For: GET /hello.html HTTP/1.1

abs_path: /hello.html

query: '\0'

The directory that is being pathed to is what is passed to abs_path. Any queries are stored in query, if none then it would simply be just a null terminator.

I might suggest debugging by setting a series of printf's at the beginning of your code to assure things are working properly.

int main(int argc, char* argv[])
{
printf("tst 2 %s\n",lookup("dir/what.htmlook/"));
printf("tst 3 %s\n",lookup("dir/what.html"));
printf("tst 4 %s\n",lookup("dir/what.css"));

char apath[LimitRequestLine + 1];
char aquery[LimitRequestLine + 1];
printf("tst 1 %d\n",parse("GET / HTTP/1.1\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);

printf("tst 2 %d\n",parse("GET /dir/hello.html HTTP/1.1\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);

printf("tst 3 %d\n",parse("GET /dir/hello.php?name=larry HTTP/1.1\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);

printf("tst 4 %d\n",parse("POST /dir/hello.php?name=larry HTTP/1.1\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);

printf("tst 5 %d\n",parse("GET /dir/hello.php? name=larry HTTP/1.1\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);

printf("tst 6 %d\n",parse("GET /dir/hello.php?name=larry HTTP/1.2\r\n",apath,aquery));
printf("  path is %s\n",apath);
printf("  query is %s\n",aquery);
 . . .
2
  • my parse code exactly produces the same values and my lookup function is also consistent with the specs but still i am getting cat.exe and non-existing file checks as red. Please see, I have only implemented parse and lookup by now. Do i also need to implement load and indexes, in order to get those two errors correct? please help
    – Vinz.R
    Aug 7 '16 at 14:58
  • Load and indexes do not have to be implemented for these test cases to work. Something has to be wrong with your code for lookup and/or parse. Aug 7 '16 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .