Fix calling len() on stream in do_head