Skip to content

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

stefanodem
Copy link

No description provided.

time_t rawtime;
struct tm *current_time;
time(&rawtime);
current_time = localtime(&rawtime);

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);

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);

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);

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.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants