<- Test Directory

Custom HTTP Headers

How to set custom headers with your requests


You can easily set any headers you need by tweaking your get() or post() calls to include a header set.

We have an example of this below.


    headers={"Content-Type": "application/vnd.api+json"}

self.client.get("/api/test", headers={"Content-Type": "application/json"}

You can also set it globally by defining the on_start() section like so:

def on_start(self):
    self.client.headers.update({'Authorization': 'Bearer xxx'})
def on_start(self):
    self.client.headers.update({'Content-Type': 'application/json'})    

This guide is part of the LoadForge Directory, an index of locustfile's for use with LoadForge website and API load tests. We also provide a wizard to generate tests, and onboarding assistance for clients. Contact us should you have any questions.

LoadForge provides load testing and stress tests for websites, APIs and servers. It uses your cloud account to rapidly scale large numbers of simulated users to load test your website, store, API, or application for cheap - just cents per test!

For more help on Tests please see our official documentation. Logged in users can also use our wizard to generate a locustfile, or you can record your browser steps.

Ready to run your test?
Start your first test within minutes.