Does the speed of light vary with gravity or is constant in space?
The speed of light is the same in all inertial frames of reference. This implies that no matter what the speed is at which the observer is traveling and whether s/he is traveling towards the beam of light or away from it, the velocity of light is the measured as the same.
This was one of the fundamental postulates of Einstein's Theory of Special Relativity. Ten years after this, Einstein in his Theory of General Relativity analyzed the change in the speed of light due to gravity. In the form of an equation the speed of light was given as: c' = co(1 + g/c^2), where g is the gravitational potential.
The following is an illustration of how the speed of light as measured by an observer would change due to gravity. A person would always measure the speed of light where s/he is as the same but there would be a marked slow-down in the speed of light measured if it were approaching an object with a large gravitational pull. Taking the example of a black hole, the speed of light when measured by an observer not affected by the gravitational forces would gradually drop to zero as it got closer to the black hole. On the other hand a person falling into a black hole would measure the speed of light away from the black hole as being faster than the speed of light around her/him.