Don't Let That Negative Nancy Get To You
Seek to understand
The most important component in dealing with someone's behaviour is understanding where it comes from. If a person was raised in a negative household and was constantly surrounded by pessimists, chances are, they haved adopted similar attitudes. Everyone is born with and later develops different coping skills. For some, seeing the worst-case scenario is completely natural, and it isn't possible for them to see anything else. As frustrating as that may be for you, aim to understand why they are being so negative, and it may be easier for you to not let their negative attitudes get you down.
Recognize it's not about you
Often a pessimistic friend speaking in a negative way has nothing to do with you at all. It may be hard to see it that way when she is making hurtful comments directly at you, but it often stems from something within that person. She may make a passive-aggressive comment about your behaviour or talk down to you about a situation you are in, and that may cut you deeply. But if you take a moment to step back and ask yourself why she would say or do such a thing, you may come to see that the reason has far more to do with her self-perception and very little to do with you. Negative people often spend so much time consciously or subconsciously criticizing themselves that they welcome the opportunity to take those emotions out on someone else, even if that person doesn't deserve it. It isn't necessarily correct behaviour, but it is human behaviour, and though we may not like it, it helps to understand it.
Tune it out
If you've tried to understand and rationalize someone's negativity and you still can't make heads or tails of their behaviour, then all you can do to protect your feelings is tune that person out. This doesn't mean completely detach yourself from the person. Simply make a conscious decision to not let their negative talk get to you, and it should be enough to sustain your mental well-being. The fact is, the person is your friend for a reason, so focus on the good things about your companion, and let her negative words roll off you. Remain positive yourself, and you will feel far better for it.