URI processing code moved to a separate function. This allows to reuse it in the upcoming SPDY module.