We investigate the characteristics of a relativistic magnetized fluid flowing around a corner. If the flow is faster than the fast-magnetosonic speed the non-smooth boundary induces a rarefaction wave propagating in the body of the flow. The subsequent expansion is accompanied with a very efficient increase of the flow speed and bulk Lorentz factor γ. We apply this ”rarefaction acceleration mechanism” to the collapsar model of gamma-ray bursts, in which a relativistic jet initially propagates in the interior of the progenitor star, before crossing the stellar surface with a simultaneous drop in the external pressure support. We integrate the steady-state equations using a special set of partial (r self-similar) solutions. The use of these solutions degrades the system of the complex, non-linear, 2nd order partial differential equations into a system of two 1st order ordinary differential equations whose integration is straightforward. For the conditions expected in a gamma-ray burst, a fully analytical solution can be obtained. The aim of this work is to better understand the results of recent timedepended numerical simulations and show that rarefaction acceleration is a plausible mechanism in gamma-ray burst outflows.