Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4631

HttpUtils.toAbsoluteUri should use request.getServerPort() instead of request.getLocalPort()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.7
    • 2.5.7, 2.6.4, 2.7.1
    • JAX-RS
    • None
    • Novice

    Description

      I believe the toAbsoluteUri() helper method should use the getServerPort() method of HttpServletRequest.

      The host name is already taken from the Host header, so it's inconsistent to return the port number of the interface on which the request was received, instead of the port value contained in the Host header.

      Anyhow I'd presume that the client would expect to receive an URL based on the address it used.

      I run into this when I put an SSH tunnel to a server where the CXF-based
      application was running:
      ssh -L 5555:localhost:80 myappserver
      Although I send requests to:
      http://myapp:5555/path
      the returned URLs are like:
      http://myapp/path2

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            jboch Jakub Bocheński
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: