Search code examples
jmeterhostname

JMeter: How to supply a hostname which contains a forward slash in JMeter user defined variables?


The hostname being supplied to the JMeter test plan, contains a forward slash and has been defined in the User defined variables section. However, each time the test is run, the following is seen in the response message:

Response message:Non HTTP response message: Illegal character found in host: '/'

The hostname provided: Jmetertest.com/test

Is there any way around this? Thanks in advance! :)


Solution

  • A DNS hostname cannot contain slash.

    The Internet standards (Request for Comments) for protocols specify that labels may contain only the ASCII letters a through z (in a case-insensitive manner), the digits 0 through 9, and the hyphen-minus character ('-'). The original specification of hostnames required that labels start with an alpha character, and not end with a hyphen

    So you need to split hostname from the URL Path

    i.e. in the following URL:

    https://example.com/foo?bar=baz
    
    • https - the protocol
    • example.com - is the hostname
    • /foo is the path
    • ?bar=baz is the query string

    In the HTTP Request sampler you can only have the following syntax:

    enter image description here

    If you put anything than allowed characters into "Server name of IP" field you will get an error.

    Theoretically it's possible to put the full URL into the "Path" field like:

    enter image description here

    But in this case configuration elements like HTTP Cookie Manager may stop working.