I don't think headscarf is there to prevent rape. What was it intended for, by the way?
I read it in my friend's Islam book that it is to prevent "maksiat". To prevent hormone-peaking men from staring and performing sex crimes.
Not covering "aurat" is a sin. That's what some of my Muslim friends say.
But it goes both ways. So, if a guy gets turned on by... hair, he is committing a sin as well.
Best to let a Muslim explain on this though.