A CGI program receives a GET request whose QUERY_STRING environment variable is set to
msg=Hi%21+5%2B3%3D8
Consider only the value of msg, the text after msg=. Find the length of the encoded value in bytes, the number of %XX escapes it contains, the length of the decoded value in bytes, and the smallest char array size in bytes that holds the decoded value as a C string. Give each as a whole number.
Unlock full course notes by signing up
Lifecycle of a CGI POST request
A browser submits a form with method POST to a CGI script written in C. Put the stages of handling this single request in the order they occur, from the browser's request to the reply it receives.
Meta-variables and stdin bytes for three requests
A web server receives the three HTTP requests below. Each request is mapped to a C program in /cgi-bin/. For each request, enter the values of REQUEST_METHOD and QUERY_STRING exactly as the server sets them. Also enter the number of bytes the program should read from standard input. Bodies are shown exactly as transmitted, with no trailing newline.
Cost of starting a process for every CGI request
A small server runs a C order-lookup program through CGI on a machine with 4 CPU cores. Profiling shows two costs for each request. Creating the process and starting the program takes 12 ms of CPU time; this covers fork, exec, dynamic linking and opening a database connection. Handling the request itself takes a further 3 ms of CPU time. Assume the work is CPU-bound, requests spread evenly over the cores, and nothing else runs on the machine.
Find:
the CPU time per request, in ms, as a whole number;
Finding the faults in a CGI POST handler
A student writes this CGI program to echo a POST request body back to the browser. The standard headers are included and the program compiles without warnings.
Which of the following statements about this program are true? Select all that apply.