In the worst case, there's the advice from Richard Ballantine's "Richard's Bicycle Book". Note that Richard was a dog-lover himself, and this was a last resort if an attacking dog is seriously endangering you.
"If the dog attacks: one defense is aerosol pepper sprays made for this purpose. They have a range of about ten feet and are light enough to clip to your handlebars. A water pistol loaded with a water-amonia solution will also work but is a good deal less convenient. If you have neither of these and can't or won't climb a tree get a stick or a large rock. No? The bicycle pump. Try to ram it down his throat. In any event, don't cower or cover up, because the dog will only chew you to ribbons. Attack. Any small dog can simply be hoisted up by the legs and his brains dashed out. With a big dog you are fighting for your life. If you are weaponless try to tangle him up in your bike and then strangle him. Kicks to the genitals and which break ribs are effective. If you have got a pump or a stick hold it at both ends and offer it up to the dog horizontally. Often the dog will bit the stick/pump and hang on. Immediately lift the dog up and deliver a very solid kick to the genitals. Follow up with breaking the dogs ribs or crushing its head with a rock. If worst comes to worst ram your entire arm down its throat. He will choke and die. Better your arm than your throat."