When trying to access cat.html
in pset6 on my local host, I get a 505: HTTP Version Not Supported
error in both the browser and the terminal where my server is running.
According to my server.c
code, these are the conditions that would make this error appear:
printf("http=%s#\n",http);
if (http == NULL)
{
printf("it's null\n");
}
if (strcmp("HTTP/1.1", http))
{
printf("strcmp\n");
}
// if (http == NULL || strcmp("HTTP/1.1", http) != 0)
if (http == NULL || !strcmp("HTTP/1.1", http))
{ // http version not supported
error(505);
continue;
}
changing the if statement to if (http == NULL || strcasecmp("HTTP/1.1", http) != 0)
still gives me the same error.
or this
char* space = strchr(line, ' ');
int length = space - line;
char buffer[length + 1];
if (buffer[length + 1] != '/')
{
error(505);
continue;
}
strncpy(buffer, line, length);
buffer[length] = 0;
When I print out http
, it shows http=HTTP/1.1#
, so I attempted a simple hacky solution that added the pound sign to the strcasecmp
comparison, but it doesn't get rid of the error.
About a month ago, I spent a lot of time on the slack channel as well as with the TAs on my offline course, and they didn't quite understand what was going wrong either.
EDIT:
http
is defined like this:
char* http = requestLine[HTTP_VERSION];
http[8] = '\0';
(I can post more code snippets if needed)
printf("http=%s#\n",http);
explains why you get that#
at the end. You put it there.http