The University of Colorado recently put up a list of 10 tips to help people deter rape, but it drew a lot of criticism and was deleted from their site. The most heavily criticized tip was "Vomiting or urinating may convince the attacker to leave you alone." This is incredibly offensive to me because when I was a child my grandmother told me if I was ever being raped I should poop myself. Vomiting and urinating are gross, but they're not gross enough to stop most people from raping, that's just common sense. Crapping on the other hand is something most people can't look past. No one wants poo poo all over them, it can spread dangerous bacteria. While it is not guaranteed to work, it certainly doesn't hurt to try.
Another tip was "Tell your attacker that you have a disease or are menstruating." This is a really stupid tip especially for men. You can't tell a rapist you're menstruating when you're clearly a dude. Then again that might make them laugh hard enough you can kick them and escape, who knows. The thing about saying you have a disease is it usually comes off as a blatant lie, the same with menstruation. If you don't look the part then just saying it won't be enough. You better look like you have lots of diseases otherwise the rapist won't buy it.
Ultimately, the best rape defense are those female condoms with the spiky teeth that latch onto the rapist's penis. If you're a man it may be a little more uncomfortable to install this device, but it probably works. Anything else people tell you is just unproven advice or old wives' tales. Even pepper spray isn't a sure fire method because you have to get it out of your pocket which is difficult to do in the moment of a surprise attack. Just use the spiky female condom.