Overview
You can easily set any headers you need by tweaking your get() or post() calls to include a header set. This is commonly used for authentication on an API (see api examples) The examples below show two methods of setting headers. You can set any key-value headers you need with LoadForge.Code
Below we set our POST requestsContent-Type to application/vnd.api+json and
the GET request to application/json within the same test.
Global Headers
You can also set headers globally by defining the on_start() section as shown below. This will ensure ALL requests have the custom header added.Custom Host Header
Sometimes you need set a custom host header, for example if you are testing against an IP address or a non-standard port. You can do this by setting theHost header:
LoadForge is powered by locust, meaning open source locust users can copy this script as well.
If you are a locust user, consider importing your script to LoadForge to supercharge your testing!