It depends. Some may not like this but if I dog runs up to me while I am walking my dog and starts growling and attempting to attack, I will strike their nose/throat. One can also raise their voice. Additionally, if you have a weapon or a stick, you should definitely use it.
Obviously if it a small dog, I would take less drastic measures, but if it is a dog as strong as pitbull, I would not hesitate to use necessary force to protect myself. It is on the owner to keep the dog leashed and away from other people.
Not OP, but never turn your back and run - to a growling dog. I was once stuck with an unfriendly pitbull in a high fenced backyard(the dog's backyard). Once it is staring and growling at you, try to slowly back out of its territory. You will definitely find it hard to take your eyes off it.
Stand your ground in full posture, get ready for it to launch at you. Dodge hard left or hard right while throwing your hands infront of you (only if you have thick sleeves), I luckily had a thick winter coat and it nibbed the sleeve as I jumped hard left (Kind of like the matadors). It recovered and got back to the low growl staring contest before launching again.
It also matters where you position yourself, after it launches their inertia takes them some time to recover which gives you time to get closer to your exit. Just a few more of these and you are on your way out of trouble.
The owner luckily came out after it's second launch at me. It launched again at our hands when I tried to shake the owners hand to show I am friendly (not a great idea once they think you aren't). He keeps telling all my friends I am afraid of dogs..
The dog was calm and peaceful when I had entered the yard, I made the mistake of pulling my hoody over my head, it did not recognize me as the same person after that. Don't change your appearance especially when on foreign territory.
Looking back, the thought of fighting it physically never crossed my mind - I got tense and recognized I shouldn't show fear or my back. Once I figured I could survive dodging side to side, it was a relief.
TLDR - Dont turn your back, get ready to dodge and move as many times as it takes, also avoid changing appearance on foreign dog territory.
Great idea for a self defence class. I am an amateur in dog fights though so don't go starting fights with dogs just based on this story/method.
If I ever am unfortunate to do it again, I might try some loud, strict voice commands to try to override the attack mode(you get a few seconds of conversation between growl/stare and launch).
Obviously if it a small dog, I would take less drastic measures, but if it is a dog as strong as pitbull, I would not hesitate to use necessary force to protect myself. It is on the owner to keep the dog leashed and away from other people.