Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-2930

Missing hostname in ts.client_request.get_url()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0.0
    • 5.1.0
    • Lua, Plugins, TS API
    • None

    Description

      In Linux TPROXY forwarding mode ts.client_request.get_uri() omits hostname from the returned url - responds with "http:///pathname?parameters" instead of "http://hostname/pathname?parameters". This happens in the context of early state hooks up to and including TS_HTTP_POST_REMAP_HOOK.

      In case of cacheurl.so rewrite on the URL, hostname reamains empty even after post_remap.

      Here're the steps to reproduce the problem - a global lua plugin (plugins.config):
      ==========[cut]==========
      function do_global_txn_start()
      print('==========[cut]==========')
      print ('do_global_txt_start: ' .. ts.client_request.get_url())
      end
      function do_global_txn_close()
      print ('do_global_txn_close: ' .. ts.client_request.get_url())
      print('==========[cut]==========')
      end
      function do_global_os_dns()
      print ('do_global_os_dns: ' .. ts.client_request.get_url())
      end
      function do_global_pre_remap()
      print ('do_global_pre_remap: ' .. ts.client_request.get_url())
      end
      function do_global_post_remap()
      print ('do_global_post_remap: ' .. ts.client_request.get_url())
      end
      function do_global_read_request()
      print ('do_global_read_request: ' .. ts.client_request.get_url())
      end
      function do_global_send_request()
      print ('do_global_send_request: ' .. ts.client_request.get_url())
      end
      function do_global_read_response()
      print ('do_global_read_response: ' .. ts.client_request.get_url())
      end
      function do_global_send_response()
      print ('do_global_send_response: ' .. ts.client_request.get_url())
      end
      function do_global_cache_lookup_complete()
      print ('do_global_cache_lookup_complete: ' .. ts.client_request.get_url())
      end
      function do_global_read_cache()
      print ('do_global_read_cache: ' .. ts.client_request.get_url())
      end

      Requesting same URL - http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png - in 4 different scenarios:
      1. empty cache (MISS) without cacheurl.so activated
      2. HIT request without cacheurl.so activated
      3. empty cache (MISS) with cacheurl.so activated
      4. HIT request with cacheurl.so activated

      cacheurl.config consists the following:
      http://[\/](yimg\.com)/(.) http://$1.internal/$2

      Here's my traffic.out output:

      1. MISS without cacheurl.so
      ==========[cut]==========
      do_global_txt_start: /
      do_global_read_request: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_pre_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_post_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_os_dns: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_cache_lookup_complete: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_request: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_read_response: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_response: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_txn_close: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      ==========[cut]==========

      2. HIT without cacheurl.so:
      ==========[cut]==========
      do_global_txt_start: /
      do_global_read_request: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_pre_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_post_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_read_cache: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_cache_lookup_complete: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_response: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      do_global_txn_close: http://l.yimg.com/os/mit/media/m/base/images/transparent-1093278.png
      ==========[cut]==========

      3. MISS with cacheurl.so:
      ==========[cut]==========
      do_global_txt_start: /
      do_global_read_request: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_pre_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_post_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_cache_lookup_complete: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_os_dns: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_request: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_read_response: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_response: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_txn_close: http:///os/mit/media/m/base/images/transparent-1093278.png
      ==========[cut]==========

      4. HIT with cacheurl.so:
      ==========[cut]==========
      do_global_txt_start: /
      do_global_read_request: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_pre_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_post_remap: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_read_cache: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_cache_lookup_complete: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_send_response: http:///os/mit/media/m/base/images/transparent-1093278.png
      do_global_txn_close: http:///os/mit/media/m/base/images/transparent-1093278.png
      ==========[cut]==========

      Attachments

        Activity

          People

            kichan Shu Kit Francis Chan
            ngorchilov Nikolai Gorchilov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: