May 2019
Intermediate to advanced
478 pages
11h 21m
English
The serve_resource() function sends a connected client a requested resource. Our server expects all hosted files to be in a subdirectory called public. Ideally, our server should not allow access to any files outside of this public directory. However, as we shall see, enforcing this restriction may be more difficult than it first appears.
Our serve_resource() function takes as arguments a connected client and a requested resource path. The function begins as follows:
/*web_server.c except*/void serve_resource(struct client_info *client, const char *path) { printf("serve_resource %s %s\n", get_client_address(client), path);
The connected client's IP address and the requested path are printed to aid in debugging. In a production ...
Read now
Unlock full access