كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(13)
Chapter: The prohibition of spitting in the masjid, during prayer and at other times. The prohibition of a praying person spitting in front of him or to his right
(13)
باب النَّهْىِ عَنِ الْبُصَاقِ، فِي الْمَسْجِدِ فِي الصَّلاَةِ وَغَيْرِهَا ‏‏
Sahih Muslim 550 a

Abu Huraira reported that the Messenger of Allah (ﷺ) saw some sputum in the direction of the Qibla of the mosque. He turned towards people and said:

How Is it that someone amongst you stands before his Lord and then spits out in front of Him? Does any one of you like that he should be made to stand in front of someone and then spit at his face? So when any one of you spits, he must spit on his left side under his foot. But if he does not find (space to spit) he should do like this. Qasim (one of the narrators) spat in his cloth and then folded it and rubbed it.
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَزُهَيْرُ بْنُ حَرْبٍ، جَمِيعًا عَنِ ابْنِ عُلَيَّةَ، قَالَ زُهَيْرٌ حَدَّثَنَا ابْنُ عُلَيَّةَ، عَنِ الْقَاسِمِ بْنِ مِهْرَانَ، عَنْ أَبِي رَافِعٍ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم رَأَى نُخَامَةً فِي قِبْلَةِ الْمَسْجِدِ فَأَقْبَلَ عَلَى النَّاسِ فَقَالَ ‏ "‏ مَا بَالُ أَحَدِكُمْ يَقُومُ مُسْتَقْبِلَ رَبِّهِ فَيَتَنَخَّعُ أَمَامَهُ أَيُحِبُّ أَحَدُكُمْ أَنْ يُسْتَقْبَلَ فَيُتَنَخَّعَ فِي وَجْهِهِ فَإِذَا تَنَخَّعَ أَحَدُكُمْ فَلْيَتَنَخَّعْ عَنْ يَسَارِهِ تَحْتَ قَدَمِهِ فَإِنْ لَمْ يَجِدْ فَلْيَقُلْ هَكَذَا ‏"‏ ‏.‏ وَوَصَفَ الْقَاسِمُ فَتَفَلَ فِي ثَوْبِهِ ثُمَّ مَسَحَ بَعْضَهُ عَلَى بَعْضٍ ‏.‏
Reference : Sahih Muslim 550a
In-book reference : Book 5, Hadith 66
USC-MSA web (English) reference : Book 4, Hadith 1121
  (deprecated numbering scheme)