Repository: locustio/locust

Issue:
FastHttpLocust gives error when using valid url.
When using **FastHttpLocust** with an valid URL, the following error is emitted.
```
LocustError: Invalid host (`https://hostname/path`). The specified host string must be a base URL without a trailing slash.
```
The regex `r"^https?://[^/]+$"` in file `locust/contrib/fasthttp.py` seems to be wrong.

It maches `https://hostname` and not `https://hostname/path` error message warned about `https://hostname/path/`

### Environment settings

- OS: Windows 10
- Python version: 2.7
- Locust version: 0.13.5



Discussion:
I now see what I did wrong. You are supposed to **only**  add the **hostname** as a startup parameter. I was testing a service behind a proxy, so I added the service path to the host parameter. If I put the service path inside the locustfile it all worked fine.

But this kind of prevents you from using the same locustfile on multiple services without making changes to the locustfile.

Do the maintainers have any thoughts on this?
Hi Lars-Kristian! I have got this error myself, sometimes and agree that it is a bit limiting. But the risk of user errors, if we allow a full path in the hostname is pretty big (and we'd need to rename the parameter to something like "base url" instead). If you want to supply arbitrary parameter to your test, you can use env vars.

Something like this:

`HOST_WITH_PATH=https://hostname/path locust ... `(I dont remember the syntax to set env vars in Windows I'm afraid)

in your test:

```
class MyLocust(FastHttpLocust):
...
    host = "http://whatever"
```

```
class MyTask(TaskSet):
...
    self.client.request("POST", os.env["HOST_WITH_PATH"], ...
```

In a distributed test you'd need to set the env var on the slaves.
Thanks for a great answer.

I am only testing locust to see if this is something my team can use, and my initial impression is very good.

I have very limited knowledge of the system, so I am not familiar with the implications of allowing a "url base" instead of only host.

The reason to my confusion is that this error message was only emitted when using the FastHttpLocust and not HttpLocust. I read in the documentation that FastHttpLocust and HttpLocust might not work the same, but I did not imagine the input parameter to locust to be one of them.

I would also suggest to improve the error message. My initial thought after reading it was "Yes, my url is a base url without a trailing slash".

I like what I see and I am going to experiment more with this system. Thanks for making it, and I see it as a very useful system.

Resolving patch:
diff --git a/locust/contrib/fasthttp.py b/locust/contrib/fasthttp.py
--- a/locust/contrib/fasthttp.py
+++ b/locust/contrib/fasthttp.py
@@ -76,8 +76,8 @@ def __init__(self):
         super(FastHttpLocust, self).__init__()
         if self.host is None:
             raise LocustError("You must specify the base host. Either in the host attribute in the Locust class, or on the command line using the --host option.")
-        if not re.match(r"^https?://[^/]+$", self.host, re.I):
-            raise LocustError("Invalid host (`%s`). The specified host string must be a base URL without a trailing slash. E.g. http://example.org" % self.host)
+        if not re.match(r"^https?://[^/]+", self.host, re.I):
+            raise LocustError("Invalid host (`%s`), must be a valid base URL. E.g. http://example.com" % self.host)
         
         self.client = FastHttpSession(base_url=self.host)
 


Test patch: