-
Notifications
You must be signed in to change notification settings - Fork 605
Stefano - C-Web-Server #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
time_t rawtime; | ||
struct tm *current_time; | ||
time(&rawtime); | ||
current_time = localtime(&rawtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty much exactly what I have. Well done.
body | ||
); | ||
|
||
int response_length = strlen(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also set int response_length = sprintf(...)
, which returns the length of the sprintf
.
srand(time(NULL)); | ||
char random_number_string[20]; | ||
int random_number = rand() % 20; | ||
sprintf(random_number_string, "%d", random_number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's smart to print this to a string because of what send_response()
accepts.
// Read the three components of the first request line | ||
|
||
sscanf(request, "%s %s", method, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also want to add an http_version
to this sscanf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback Grant! I'll try to incorporate it today.
No description provided.