It is in [SN 16.11][1]. > ‘Your outer robe of patches is soft, Kassapa.’–‘Venerable sir, let the Blessed One accept my outer robe of patches, out of compassion.’–‘Then will you wear my worn-out hempen rag-robes? ’–‘I will, venerable sir.’ Thus I offered the Blessed One my outer robe of patches and received from him his worn-out hempen rag-robes. However, the English translation doesn't mention that the buddha wore a cloth wrapped to a dead body. In the pali version it says the robe was 'paṃsukūlāni (rags discarded on the ground)'. [1]: https://suttacentral.net/en/sn16.11