Pete goes to town
--#--
Where should Pete go to town? And where should he eat?
Why not surf down to Miami and chow down at
Burger King's Web site?
I mean, for Pete's first meal, why not pick^h^h^h^hfeast on IIS4.0/NT?
Actually, Burger King has a very educational "nutrition wizard" on
its site that we can use to glean some working knowledge of HTTP POSTS
without doing any harm. The nutrition information is amazingly helpful,
too.
Go to http://www.burgerking.com/nutrition/nutrition02.asp and take a
look at the source code. This one's a little tricky, so stay awake.
For starters, let's say you want to know the nutritional content of a
Double Whopper with cheese. Go ahead, just try it through a Web browser.
You'll have to click through a few screens, but you should find a
choice of Double Whopper with Cheese and all it's condiments pretty easily.
You'll notice in the page source that the form posts back to nutrition02.asp.
But if you look in your brower's address window, you'll see the results
display comes back from nutrition01.asp.
Use the values in the <SELECT NAME= so> and <input type="checkbox"> fields to
send Pete back with one (sc=1) Double Whopper with Cheese Sandwich (so=55) all the way. Note
that all the condiments have a checkbox name of "li," so mayonnaise is
"li=55" pickles are "li=63," etc.
String host = "www.burgerking.com";
String url = "/nutrition/nutrition02.asp";
String request =
"so=55&sc=1&li=86&li=84&li=79&li=65&li=55&li=63&li=50&li=44&li=58&li=57";
Burger King's IIS instance comes back with this response:
HTTP/1.1 302 Object moved
Server: Microsoft-IIS/4.0
Date: Sat, 30 Oct 1999 17:05:04 GMT
Location: nutrition01.htm?ei=missing_data
Connection: Keep-Alive
Content-Length: 152
Content-Type: text/html
Set-Cookie: ASPSESSIONIDGGQQQGFI=GMJBIBMAELEMEMMNFOGEAIFL; path=/
Cache-control: private
Object moved
Object Moved
This object may be found here.
Most interesting. We get a 302 status code and a Location:
nutrition01.html?ei=missing_data line in the header. IIS also
drops a cookie on us, but we'll ignore it.
The Location: header is a clue. This is why the answer always comes
back from a different page than you'd expect. The ASP script sends
back an answer, but also tells the browser it's on a different page,
which the browser then goes and retrieves. The missing_data
part is bad news, though. Something is wrong. If you go to
/nutrition/nutrition01.htm?ei=missing_data, you'll just
get a chance to start the Nutrition Wizard all over again.