A HTML form can be written to submit data using either the
GET or POST method.
Describe how the form data is submitted to the web server in each
of these cases. Detailed answer required.
Why is submitted form data URL-encoded? Explain
why it's necessary, and discuss what could happen if it wasn't
encoded.
In the lecture, the comment was
made that a CGI program could be (relatively) easily written to
accomodate either the GET or
POST request methods. Discuss reasons why you
might wish to do this. Make sure you understand the issues
here!
Is it possible that a browser could send information to a CGI
using (effectively) both GET
and POST at the same time? In other words, is
it conceivable that the URL could be of the form used in the usual
GET request (ie. data appended after a
?), and additionally have a request body
containing the POST data? Discuss.
Hard question: in a popular (but unnamed) text on CGI programming,
the following lines of Perl are suggested for decoding a URL encoded
string:
$info =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$info =~ s/\+/ /g;
@fields = split (/&/, $info);
... etc ...
There is a serious problem with the order of execution in
this code. What is it? Explain carefully.
Research[1]:
look up your Perl reference (whichever one you have chosen to use) and
carefully figure out what the following line of code is actually
doing (we'll be using it in the next lecture!):
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
It's actually not so difficult!
Research: find out about how the the
PATH_INFO and
PATH_TRANSLATED variables are used.