First thing, try to understand animal behavior. Dogs will become more aggressive if they think you are intimidated. Don't respond to their barks and nips. don't yell. Stand still -- arms down but fists clenched ready just in case. Don't make eye contact, which signals a challenge. In short, don't panic. If they are seeming to become less aggressive, try very slowly walking away.
Next, if the dog won't disengage, try loud, authoritative commands, like "No!," "Stay!" and "Heel!" Dogs that have had some degree of training should know at least one of those commands and might at least pause to consider what's being commanded. The more you appear to be in control and not simply reacting to the animal's aggression, the better.
Whatever you do, don't run. If you are on a bike, push it rather than try to out run them. Fast-moving "prey" are an invitation for a chase.
If you have something close to you to throw, try using that to distract them. Don't throw it at the dog. Just toss it away from you so the dog sees it. I doubt he'll fetch it, but it shows you have the "power" to strike the animal from a distance.
If all fails, and you are being bitten, protect your face and neck. Try punching the dog's nose which is their most sensitive body part that's coming at you. If you have the strength, you can try grabbing the dog by the throat, but that only lasts a few seconds before they wiggle loose. A sharp punch or kick causes pain that last longer.
If you can evade, go for higher ground. Jump onto a rock wall, car hood, or anything else that gives you more height. It may prevent the dog from reaching you at all, but at least it helps protect your face and neck. This might be the best plan if attacked by a pack of dogs.
Afterward, seek medical attention. Animal bites are almost as bad as human bites. Infections can become life-threatening.
If you escape and have a moment out of danger while in view of the dogs, take a pic on your phone. The pics will help identify the dog/s later when you report the attack to the Cops. Don't bother reporting to the Humane Society. They will be contacted by the police if needed. Report it even if you weren't injured. Menacing dogs can hurt the next person who tries to run.
When I was a kid, I used to go door-to-door all the time (seems like more days than not) selling fundraiser stuff for band, school, Boy Scouts, my Church youth group, etc. I also sold newspapers for myself on my bike. I've dealt with my share of dogs wanting to chase me. The best, most reliable response was to stop, freeze and wait. If you aren't behaving as the dog hoped (running, screaming in fear or fighting), they will also stop to size the situation up. 9 times out of 10, they will go away since you're not "playing" their game. You aren't afraid, combative or anything else. You're just still .... quiet ,,, waiting.
Pit Bulls are going to be the exception. When they decide to attack, they go all in. They bite and refuse to let go. They will continue to attack relentlessly until they win. Standing still is difficult, as well as ill-advised, if you're being mauled. At this point, you only have one option -- FIGHT! I've seen stories of Pit Bull attacks. One man was jogging and had 3 of them attack. He was left without feet and with several other major injuries. The thing the victims all had in common was how determined the Pit Bulls were. Once they made up their minds to attack, getting them to stop was nearly impossible.
They say once a dog tastes human blood, they have to be put down. I believe that to be true, if for no other reason than they have already shown they have no problem attacking humans. This is why reporting them is important.
Animals are animals, no matter how well-trained, "sweet" or socialized you think yours are. My 90 lb German Shepherd was a completely friendly dog. Never even looked like he was thinking of hurting a person. But, when people came over, I put him in his pen or kept him on a lead at my side. I wanted to make sure if anything happened, he was always within my control. You can't control the environment 100% of the time. Things can happen to make them think there is danger. They react on instinct. A responsible owner would control their dogs and not allow them to roam freely. I personally think any dog roaming the streets needs to be reported and picked up by animal control or whoever is in that role. Safer for the dog, and safer for everyone.