diff --git a/c302.c b/c302.c index 01da61c..d5d01ac 100644 --- a/c302.c +++ b/c302.c @@ -22,8 +22,8 @@ int main(int argc, char **argv) { return 1; } srand(time(NULL)); - unsigned int i = rand() % (sizeof(urls)/sizeof(char*)); - const struct iovec iov[3] = {{HTTP302HEAD, sizeof(HTTP302HEAD)}, {(void *)urls[i], urlsl[i]}, {"\r\n\r\n", 4}}; - writev(1, (const struct iovec *)&iov, 3); - return 0; + uint32_t i = rand() % (sizeof(urls)/sizeof(char*)); + uint32_t len = sizeof(HTTP302HEAD) - 1 + urlsl[i]; + const struct iovec iov[3] = {{(void *)&len, sizeof(uint32_t)}, {HTTP302HEAD, sizeof(HTTP302HEAD)-1}, {(void *)urls[i], urlsl[i]}}; + return writev(1, (const struct iovec *)&iov, 3) != len+sizeof(uint32_t); } diff --git a/c302.h b/c302.h index cfff927..6da1e13 100644 --- a/c302.h +++ b/c302.h @@ -4,7 +4,7 @@ #include #define SERVER_STRING "Server: C302 by Fumiama/1.0\r\n" -#define HTTP302 "HTTP/1.0 302 Moved Temporarily\r\n" +#define HTTP302 "HTTP/1.1 302 Found\r\n" #define LOCATION "Location: " #define HTTP302HEAD HTTP302 SERVER_STRING LOCATION