if a dog attacks, it has been trained.
when an untrained dog operates on instinct alone, and they approach you, they are not in 'defense' mode. about the only time they would follow through with an attack is if your back is turned to them.
dogs that get aggressive outside their territory are cowards. they will bluff, charge, and try to be the Alpha. your response to them determines how much more aggressive they will be. they can sense your fear, and will feed off that. but if you match their aggressiveness by taking a firm stand, and yelling at them in your meanest voice, they will most often back down.
i've told about my encounters with dogs before, but i can tell it again.
couple years back i was walking home from work, around midnight, its during the winter. normally i walk with headphones on but that night my cd player batteries died. thats the only way i head the dogs paws hitting the asphalt. no growling, no barking, just a pitbull charging towards me from behind. soon as i faced him he veered off sharply. the pit circled me while i kept my front towards him and reached for my industrial size bottle of pepper spray. when he was within 4 feet, i blasted him in the face.
he sneezed it off and came back for seconds. then i started running to put some distance between us.
at that time, i wasnt carrying and didnt even own a gun.
a few months ago, i was heading out, still on my doorstep and a couple kids were walking two dogs, unleashed. one charged towards me and had me cornered. vicious barker, and kept inching closer. the dumb kids didnt even try to restrain the dog, they kept calling it from the street.
the dog eventually gave up but i was very close to dropping that dog right on my doorstep. i couldnt get back in without turning around to unlock the door, and i couldnt get anywhere else.
usually a gruff word or two will dissuade a dog that tries to be aggressive.