HTTP purge request?

I was just curious to wonder how, if possible, one might issue an HTTP purge request method with Gatling/Scala to clear cache on a cache/proxy server as part of load/performance test setup/teardown.

Something like this in Java but Scala/Gatling equivalent:

Or I suppose one should write a Java class implementing that and call that through Scala via Gatling instead?

We’ve just introduced before/after hook:

However, whatever code you write in your simulation body will be executed when the simulation is instanciated, so you can get the same effect as before hook.

You won’t be able to use Gatling DSL for this though.

I advise you write this directly in Scala, and use the HTTP client we ship: async-http-client:

import com.ning.http.client._

val client = new AsyncHttpClient

try {
client.executeRequest(new RequestBuilder(“PURGE”).setUrl(“”).build).get
} finally {