How you handle it mostly depends on where you live.
Here in Northern Colorado, there are lots of cyclists. Some of them are real jerks to automobile drivers, so lots of us try to be "good will" ambassadors. Smile and wave.
If someone repeatedly threw stuff at me, or tried to hurt me, I'm not sure what I'd do. Probably try taking a picture of them with my phone camera, or a helmet camera, and sending it to the police. If that did not work, I'd probably start carrying a loaded pistol to even the odds a little bit.