Can all gifts contain Eggs?
If there is no free space in the Egg inventory, it's impossible to obtain an Alola Egg. Is this checked when the Gift is received whether you open it or not (much like the eggs), or it is checked at the moment you try to open it?
You can always obtain an egg.
I tested this myself with multiple gifts. I followed some gifts I received when I had no egg space, and when I finally had a free spot I opened them and received a 7km egg.
It is checked the moment you try to open the gift, not when you receive the gift. If you have free space when you open the gift, you have a chance to receive an Alolan egg. Note the word chance: it is not guaranteed you'd get an egg even if you open a gift with free space.
As per this question and answer, there are cases of Pokemon receiving Pokemon from eggs that were available when the eggs were open, but not when the gifts were received.