Had an old friend of mine (gone now) who would say self-deprecating things out loud to people, and it was hilarious. He'd chase someone down who had fled when the conversation lagged for a moment...he'd ask them, "Ahhh, does that mean I'm not interesting enough to hold your attention long enough for you to say good-bye, or did you just need to run away for another excellently secretive reason?"
People who "rile", strangely enough, fascinate. Noticing a reaction sometimes points me to a value that I wouldn't have known was there because I took it so much for granted. Humans only seem to notice "mismatches" or "contrasts" that stand out, so anyone or any situation who brings something like this to my attention is offering me a strange, back-handed sort of gift.
Sometimes the assumption is mine, sometimes it's theirs - but it's always interesting to stop and do what you imagine would be a good idea for the other person to be doing. Then if you do it yourself, they will tend to follow your lead - especially if you have some degree of self-possession to determine your own motives and examine your own assumptions.
But sometimes, it riles them! It helps to explain your motives before you step into areas where defensiveness may occur.
Women, for instance, have many ways they establish "we're in the same boat" attitude as a base agreement. Sometimes women do this with mutual complaints or bitching; sometimes by addressing what is most commonly a cultural assumption about motive-in-common, (such as all women are trying to lose weight, beauty, want money, have problems with men, etc.) Sometimes women try to negotiate an agreement to not tear each other up competitively or pass judgments on each other, to not gossip, etc. Seen in this light, pretty much all these "nasty & thoughtless" topics listed above are, in fact, positive intent.
For instance, if someone is bitching about how bad things are, the best response (as Barbara Sher suggests) is to take the bitch far beyond "normal" bounds to where it gets hilarious.
If you don't fit social expectations, you'll get weird routine comments from people over and over again, "you don't look like dumb enough to want to get sweaty...except in bed." If this is the case for you, this is your chance to come up with a quip (or many quips) that can become a stock answer(s): "Yeah, athletes with brains have to hide it because they don't want to threaten those who feebly try to compete."
I have a standard reply that can make people groan and also get them thinking about assumptions. When they meet, people will commonly ask: Where do you come from? I learned to answer..."Like most people, I came from my mother, originally." Then when they repeat the question, I can say, "Oh, you mean, where was my mother located when I was born?... In a canyon." This helps them to be more specific with their questions to me. Then I can tell them that the hospital where I was born was torn down to be rebuilt across the street when the highway was widened. My mother would point to a bare spot in this canyon when we would drive over a bridge and she'd say, "that's where you were born." I have a chance to explain to them, this is why I'm motivated to examine assumptions and to question people who are questioning me what they mean, exactly. I want to set this person up from the beginning to understand that I do not question their assumptions in order to get them to defend themselves. I ask questions merely because it is all too common to misunderstand.
My intent is to gain information and to get people to think for themselves - not to incite defensiveness. To defend is the more common reaction for people who wary to being "snubbed." Defense cuts off creative thinking ability and directs the blame on to the person who "incited" the defensive reaction...which of course, I do not want them to think about me. I want to encourage people to feel free to talk to me, not shut them up.
Well, sometimes I want to shut them up. As the woman who looked for her license as the cop tried to engage her to get her admit she had a "good excuse" to be speeding, I've used the ruse that I am preoccupied if the person offers me the wrong lead. I'm using the word "lead" here as in the leading the conversational intent somewhere where I know I do not want to go because I know that it is not positive or constructive. There's a rhythm to who gets to lead, when - so watch for this rhythm and redirect when it is your turn.
But if you determine that someone knows your boundaries, and they are still "testing" these boundaries, now it's a Training Issue. If the person, (who knows better) is intentionally "messing with you," if you don't slap them down in the moment, you'll just be encouraging them to blithely disrespect you again and again. You've expressed your preferences and limits, and now you must enforce them... or cut off the relationship. Assuming that you'd like to keep the relationship going, you can try other tactics: distraction, humor, a "pattern interrupt" action. Other bright ideas are to change your pacing, slowing down or speeding up the tempo of the exchange, communicating with body language & actions...all these are handy. Some of the time, they actually work.
Communication is a tricky thing, but you get relationships out of it.
One of my rules of both thumbs is "Never Say What You Don't Want Them To Do - It Confuses The Animal." It helps to remember to "Keep Your Eyes On The Prize" and state what you do want. It allows other people to play what I'm playing, but it makes me feel a little like I'm selling something.
If I want to inform someone that they have jumped toward making a mystery assumption and I'd like to know what they did, maybe I'll ask about their motive with a story that explains why I'm so insatiably curious, (such as the one above about my birthplace).
Even if their motive was apparently a "mean" one that they suddenly are having a very hard time explaining, I've found that coming up with an innocently positive explanation for their rather obviously "nasty" comment will make them behave better towards me. Every time, (whether they are secretly imagining I'm an insufferable "PolyAnna" optimist or stupidly gullible,) as they choose the more positive explanation that I've dangled in front of them, they are acting as if they are a much nicer person. Whether they are a "nice person" or not, they're getting trained to be - by me.