Ok just to make it clear that I don't have any Arduino Ethernet shields but I will try and offer my assistance.
Briefly looking at your code, I can see a couple of errors that could be contributing to the unexpected events you are encountering.
1. The line:
client.println("User-Agent: AVR ethernet\r\n");
Should be:
client.println("User-Agent: AVR ethernet");
The extra carriage return and newline characters you have would cause the server to think you have completed your HTTP GET request.
2. You are disconnecting the Client at the wrong time. You should change your "if (client_state==STEP2)" block to be this (the yellow highlighted line is the line I changed):
if (client_state==STEP2)
{
if (client.available()) {
char c = client.read();
Serial.print(c);
client_state=STEP2;
}
[glow]else if (!client.connected())[/glow]
{ Serial.println();
Serial.println("disconnecting.");
client.stop();
delay(7000);
client_state=STEP1;
}
}
}
Hope this helps.