I guess it was and elsif because it wanted to read the full header before reading the payload. I'm not sure if the payload_length_left field is the last one from the header. I guess this chance could cause problems only if payload_length_left isn't the last field from the header. On the other hand, a little bit shocked atm which this elsif was causing problems :S. So proceeding with testing!