fix #5428 only read the stream contents once

A suggestion for a fix. I think the getRawContent might also need the change.