Time for fun
--#--
Now, let's really have some fun. Let's do some POSTS against a server,
and then we'll build a few simple programs to do our work so we don't
have to do so much typing.
Forming a POST is a little trickier than a GET. The two things to
remember are, you MUST give the server the EXACT length of your post
in a header, and you should also include a www-form mime header. Some
servers -- Apache, for instance -- can usually guess the mime type from
a well-formed POST. But others -- Netscape, for instance -- will
automatically reject a POST that doesn't state its mime type.
How do I know this? From the same sort of experimentation I'm showing
you how to do. You won't find it documented anywhere!
OK, post against a Perl script running under Apache here on Darkspell.
telnet www.darkspell.com 80
Trying 216.147.111.129...
Connected to www.darkspell.com.
Escape character is '^]'.
POST /cgi-bin/echo.cgi HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 34
name=john&game=www&domain=darkspell
As soon as you hit <Enter> the server responds, because it read 34 characters
and knew you were through. What happens, though, if you give a content length
of 24, but still send the same 34 characters? The server chops off you request
at the 25th character. If you tell the server you're sending 44 characters and
only type 34, the server just sits and waits for those other 10
characters.
As I noted, you can leave off the Content-Type: header when posting to Apache.
But what happens when you go against Netscape? Let's try The Dilbert Zone,
which runs on Netscape Enterprise Server 3.5.1.