CheeseCookie is scary. A clannie of mine found snapsot a few days ago. It was a terrifying revelation for her!
I was going to do Source Terminal recipes but work came along. I'm amused that I bring all sorts of fear into the souls of completionists.
Well, here is what I see in my session log when remembering a delicious meal in the Relay Browser:I wrote up TimeSpinnerCommand, at least for eating food. It makes all the right requests, but at the end gives an error because inv_eat returns a blank page.
Attached what I've written here (also need a line added to KoLmafiaCLI), because it's probably something simple that's missing.
use 1 Time-Spinner
Took choice 1195/2: (secret choice)
choice.php?pwd&whichchoice=1195&option=2
Took choice 1197/1: Spin and Munch!
choice.php?pwd&whichchoice=1197&option=1&foodid=9122
eat 1 Tea, Earl Grey, Hot
You gain 21 Adventures
You gain 1,000 Mojo Points
You gain 1,000 hit points
//inv_use.php?whichitem=9104&ajax=1&pwd&_=1475872346193
RequestThread.postRequest( UseItemRequest.getInstance( ItemPool.TIME_SPINNER ) );
//choice.php?forceoption=0
//choice.php?pwd&whichchoice=1195&option=2
GenericRequest request = new GenericRequest( "choice.php" );
request.addFormField( "whichchoice", "1195" );
request.addFormField( "option", "2" );
request.addFormField( "pwd", GenericRequest.passwordHash );
RequestThread.postRequest( request );
//choice.php?pwd&whichchoice=1197&option=1&foodid=2527
GenericRequest request2 = new GenericRequest( "choice.php" );
request2.addFormField( "whichchoice", "1197" );
request2.addFormField( "option", "1" );
request2.addFormField( "foodid", foodIdString );
request2.addFormField( "pwd", GenericRequest.passwordHash );
RequestThread.postRequest( request2 );
//inv_eat.php?pwd&whichitem=2527&ts=1
//RequestThread.postRequest( EatItemRequest.getInstance( food ) );
// this shouldn't be needed, since it appears the redirect from choice.php is being followed
protected boolean shouldFollowRedirect()
{
return this != ChoiceManager.CHOICE_HANDLER && this.getClass() == GenericRequest.class;
}
@Override
protected boolean shouldFollowRedirect()
{
return true;
}
Requesting: https://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1197&option=1&foodid=2527
3 request properties
Field: Cookie = [charpwd=220; chatpwd=292; PHPSESSID=bsgp2j2al17vn76n03m11t0us7; AWSALB=neaTD67huaBSQUR6e6lBIFCkqMQTJ+NqITk4Z3+jNlEEAkwKifSEXC6UuguwX37tqys//OTyQpueyFz/2iBL0N4dM6X6cz886IQoN8ZVvgTZOBpQErRJguQgZw0P]
Field: User-Agent = [KoLmafia v17.4]
Field: Content-Type = [application/x-www-form-urlencoded]
Retrieving server reply...
Retrieved: https://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1197&option=1&foodid=2527
12 header fields
Field: Transfer-Encoding = [chunked]
Field: null = [HTTP/1.1 302 Moved Temporarily]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]
Field: Server = [nginx/1.8.1]
Field: Connection = [keep-alive]
Field: location = [inv_eat.php?pwd=6dd7086db8e2581c637fe6f2b8736704&whichitem=2527&ts=1]
Field: Set-Cookie = [AWSALB=FVLruN4Ks2ZIiMNAG/oLwx3zbNzZEir/uZaFG3WIQdScF8hLhCD4roNCR4YQI6Fyi9qwXXS5uV6tJknGNxkZpLTiWc9889gysLnp3nNevVnG+s9QS6I8QTsNeHEs; Expires=Fri, 14 Oct 2016 20:32:36 GMT; Path=/]
Field: Pragma = [no-cache]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Date = [Fri, 07 Oct 2016 20:32:36 GMT]
Field: X-Powered-By = [PHP/5.3.29]
Field: Content-Type = [text/html]
class net.sourceforge.kolmafia.request.RelayRequest
Connecting to inv_eat.php...
Requesting: https://www.kingdomofloathing.com/inv_eat.php?pwd&whichitem=2527&ts=1
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1197&option=1&foodid=2527&pwd
3 request properties
Field: Cookie = [PHPSESSID=9ankv1tomq1f559i08gdn1hae2; AWSALB=E7GeUIPt5rOsrjjWFnlxGAfo41ZM4SMLKYV7RPaTE5BsuuHYgYGfFs+8wLms1zLBUfbcbxa+qkMP0yBwvnwwfpqzEWvsnuLe60DqffL7pHyXQep3vPDFwtg3meHO]
Field: User-Agent = [KoLmafia v17.4]
Field: Content-Type = [application/x-www-form-urlencoded]
Retrieving server reply...
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1197&option=1&foodid=2527&pwd
12 header fields
Field: Transfer-Encoding = [chunked]
Field: null = [HTTP/1.1 302 Moved Temporarily]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]
Field: Server = [nginx/1.8.1]
Field: Connection = [keep-alive]
Field: location = [inv_eat.php?pwd=a79ac9a729895154acfdf10a93835aac&whichitem=2527&ts=1]
Field: Set-Cookie = [AWSALB=m+uqgYfRskvqlQUVM2E+GDcd3mYSrZd62bzSDF7KQMgKIEbzI2StzFZqs1Swj8KeLu0CbM3cs4OLc1C1hQz431H1jr2Y1OCMDj4DBjSsMEglzuyGbnhI2Zb1tBdL; Expires=Sat, 15 Oct 2016 00:03:48 GMT; Path=/]
Field: Pragma = [no-cache]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Date = [Sat, 08 Oct 2016 00:03:48 GMT]
Field: X-Powered-By = [PHP/5.3.29]
Field: Content-Type = [text/html]
Server www.kingdomofloathing.com returned a blank page from inv_eat.php. Complain to Jick, not us.
Using 1 Time-Spinner...
Manual control requested for choice #1195
choice 1: (secret choice)
choice 2: (secret choice)
choice 3: (secret choice)
choice 4: (secret choice)
choice 5: (secret choice)
Click here to continue in the relay browser.
Server www.kingdomofloathing.com returned a blank page from inv_eat.php. Complain to Jick, not us.
Browser sends request for choice.phpGoing through the Relay Browser (which works, obviously):
Code:Requesting: https://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1197&option=1&foodid=2527 Retrieved: https://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1197&option=1&foodid=2527 Field: location = [inv_eat.php?pwd=6dd7086db8e2581c637fe6f2b8736704&whichitem=2527&ts=1] class net.sourceforge.kolmafia.request.RelayRequest Connecting to inv_eat.php... Requesting: https://www.kingdomofloathing.com/inv_eat.php?pwd&whichitem=2527&ts=1
I see no evidence that we actually followed the redirect. We would have seen "Requesting: inv_eat..."Code:Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1197&option=1&foodid=2527&pwd Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1197&option=1&foodid=2527&pwd Field: location = [inv_eat.php?pwd=a79ac9a729895154acfdf10a93835aac&whichitem=2527&ts=1] Server www.kingdomofloathing.com returned a blank page from inv_eat.php. Complain to Jick, not us.
I don't think that is so "clear".There isn't even anything about requesting inv_eat.php, but clearly the redirect was followed to get a blank page.
Cookie data is interesting in that we get to see that we are doing the right thing changing cookies when KoL sends us a new cookie. Removing the password hash when logging the location header seems reasonable.(On another note, it looks like password hashes should be removed from header info in debug logs? Or maybe it isn't so important with all the other cookie data, or maybe that should be removed as well.)
That's as it should be; you do a GET on redirects. So do we. Look at this loop:Here it is (with bulky responses removed). Looks like POST to choice.php and GET to inv_eat.php.
public void externalExecute()
{
do
{
if ( !this.prepareConnection() )
{
break;
}
}
while ( !this.postClientData() && !this.retrieveServerReply() && this.timeoutCount < GenericRequest.TIMEOUT_LIMIT && this.redirectCount < GenericRequest.REDIRECT_LIMIT );
}
if ( this.shouldFollowRedirect() )
{
// Re-setup this request to follow the redirect
// desired and rerun the request.
this.constructURLString( this.redirectLocation, this.redirectMethod.equals( "POST" ) );
// this.hasResult = !this.isExternalRequest && ResponseTextParser.hasResult( this.redirectLocation );
if ( this.redirectLocation.startsWith( "choice.php" ) )
{
ChoiceManager.preChoice( this );
}
return false;
}
private boolean prepareConnection()
{
if ( this.shouldUpdateDebugLog() )
{
RequestLogger.updateDebugLog( "Connecting to " + this.baseURLString + "..." );
}
{
this.execute();
}
// Response is ok or redirect
if ( this.responseCode != 200 && this.responseCode != 302 )
{
return;
}
if ( this.responseText == null )
{
KoLmafia.updateDisplay(
MafiaState.ABORT,
"Server " + GenericRequest.KOL_HOST + " returned a blank page from " + this.getBasePath() + ". Complain to Jick, not us." );
return;
}
this.constructURLString( this.redirectLocation, this.redirectMethod.equals( "POST" ) );
this.responseText = null;
while ( !this.postClientData() && !this.retrieveServerReply() && this.timeoutCount < GenericRequest.TIMEOUT_LIMIT && this.redirectCount < GenericRequest.REDIRECT_LIMIT );
Using 1 Time-Spinner...
[color=red]Manual control requested for choice #1195[/color]
choice 1: (secret choice)
choice 2: (secret choice)
choice 3: (secret choice)
choice 4: (secret choice)
choice 5: (secret choice)
[color=red]Click here to continue in the relay browser[/color]