Hostnames and Wildcards?

2 posts, 0 answers
  1. Derek
    Derek avatar
    1 posts
    Member since:
    Jun 2015

    Posted 22 Jun 2015 Link to this post

     Currently I have Fiddler's Host Remapping feature configured like so:

    127.0.0.1:10092     *WebsiteA.com
    127.0.0.1:10092     *WebsiteA.de
    127.0.0.1:10092     *WebsiteA.es
    127.0.0.1:10092     *WebsiteA.co.uk
    127.0.0.1:10092     *WebsiteA.fr
    127.0.0.1:10092     *WebsiteA.it
     
    127.0.0.1:10091     *m.WebsiteB.com
    127.0.0.1:10091     *m.WebsiteB.com.au
    127.0.0.1:10091     *m.WebsiteB.de
    127.0.0.1:10091     *m.WebsiteB.es
    127.0.0.1:10091     *m.WebsiteB.co.uk
    127.0.0.1:10091     *m.WebsiteB.fr
    127.0.0.1:10091     *m.WebsiteB.it
                           
    127.0.0.1:10093     *WebsiteB.com
    127.0.0.1:10093     *WebsiteB.com.au
    127.0.0.1:10093     *WebsiteB.de
    127.0.0.1:10093     *WebsiteB.es
    127.0.0.1:10093     *WebsiteB.co.uk
    127.0.0.1:10093     *WebsiteB.fr
    127.0.0.1:10093     *WebsiteB.it

    How can I use a wildcard for the Top Level Domain?

    I tried to use the code below in the Fiddler Rules script's OnBeforeRequest() but am not having success. How can this be done?

    if (oSession.host.Contains('.websiteB.')) {
       //oSession.host='127.0.0.1';
        oSession.m_hostIP= '127.0.0.1';
        oSession.port=10091;
       // MessageBox.Show(oSession);         
    }

     

  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 23 Jun 2015 Link to this post

    Hello, Derek--

    I'm not sure if your example is using made up names? If not, the most direct problem is that .Contains is a case-sensitive function, but the hostnames sent by clients are almost always in lowercase. Hence, asking if a hostname contains any string containing uppercase letters will almost always return false.

    Your code should look like this:

      if (oSession.host.Contains('.websiteb.')) {
        oSession["X-OverrideHost"] = '127.0.0.1:10091';
      }


    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top