Minor refactoring of the way the Uri is built from a HttpServletRequest

As discussed in pull request #427, this pull request contains some minor changes to the way the Uri object is built from a HttpServletRequest. These changes are pure refactoring and do not affect the functionality.