Experiment 6.3: Frequently Asked Questions |
int
into a string?
Support at least the necessary ones to load the example documents in htdocs. They are "text/html" for html files, "text/plain" for plain text, and "image/gif" for gif files. You will change the Content-type depending of the suffix of the file. For example, if the requested file ends with .html or .htm, then the Content-type will be "text/html". If it ends with ".gif, then the content type is "image/gif" . You don't need a configuration file for that. You can hardwire in your program the types specified above. It is up to you if you want to implement a configuration file.
Support at least the necessary ones to load the example documents in htdocs. They are "text/html" for html files, "text/plain" for plain text, and "image/gif" for gif files. You will change the Content-type depending of the suffix of the file. For example, if the requested file ends with .html or .htm, then the Content-type will be "text/html". If it ends with ".gif, then the content type is "image/gif" . You don't need a configuration file for that. You can hardwire in your program the types specified above. It is up to you if you want to implement a configuration file.
How do we determine things like the virtual root directory.
The virtual root directory is the directory the server looks up
for documents.
By default the virtual root directory of your server will be the
current directory where you execute your server. It is up to you if
you want to implement passing a different root directory as argument.
If a "../../" occurs in the URL, should we allow the user to read
files above the virtual root directory on the file system?
Make sure that the URL's do not go above the virtual root
directory. This is the least security mechanism that your http server
will have. If a URL tries to read above the virtual root return an
error.
Is there any reason you can think of why a .gif image would fail to load
properly when sent by my http server? HTML pages come up correctly, but
when I try to load a gif, it comes up in Netscape as a broken picture.
When I manually telnet to my port and request a gif, it appears to be
sending correctly, i.e. HTTP header,
followed by a blank line, and then a
bunch of control characters.
Make sure to use "\015\012" instead of "\n" for the
My web server works with one browser but not with another? How
can that happen?
(Thanks to Chris Wieringa) Any webserver that sent the Content-type for
images worked fine on both common browsers, but those that did
not do so broke down in one of the browsers.
How do I call C functions in a C++ program?
To include "C" functions in your C++ program you have to declare them as:
extern "C"
For example type in your C++ program at the beginning.
extern "C" int passiveTCP(const char *service, int qlen);
extern "C" int errexit(const char *format, ...);