There’s just so much to say about this scene though:
John’s already shaking his head, hoping for a negative answer to the question. He’s got his textbook flirt face on (check out onthelosingside’s awesome meta on this topic!) and he asks the question in just a vague enough way that he still has the benefit of the doubt if he gets rejected. But his subconscious knows what it wants and what it wants is for Sherlock NOT to have a boyfriend.
After Sherlock says he doesn’t have a boyfriend:
We see John do a few things here. First he shakes his head just a little as if he can’t even believe that Sherlock is single. Then, he licks his lips while nodding slightly. Licking your lips is well known to be a sign of attraction, especially when coupled with the smile and slight raising of the eyebrows seen here. This John Watson wants Sherlock and is both surprised and delighted that he might actually have a chance. That is, before Sherlock shuts him down and he backtracks, telling Sherlock that he wasn’t asking him out (but not that he’s straight).
In conclusion: John is attracted to Sherlock from the beginning and was totally hitting on him in this scene (◡‿◡✿)
(gif source: x)