# Pre-configure client

Sometimes you may want to reuse your [HTTP Client configuration](/docs/http-client/request-options.md) to avoid code duplication or to archive better maintainability of your code base.\
Skrape{it} supports shared client configurations by default -- you just need to configure the client properties you want to reuse using the skrape{it} DSL without calling the `response` function.&#x20;

Calling the `request` function will create a `Request` object which can then be stored to a variable.

{% hint style="info" %}
The DSL is design to behave like fluent API, which means it will always return the return value of the last thing that was called inside the `skrape` lambda function.
{% endhint %}

```kotlin
val myPreConfiguredClient = skrape(HttpFetcher) {
    request {
        timeout = 10_000
        headers = mapOf("some-custom-header" to "some-value")
        followRedirects = true
    }
}

@Test
fun `can use preconfigured client straight away`() {

    myPreConfiguredClient.response {
        status { code toBe 200 }
        headers.getValue("some-custom-header") toBe "some-value"
    }
}

@Test
fun `can use preconfigured client but slightly modify`() {

    myPreConfiguredClient.apply {
        request {
            followRedirects = false
        }
    }.response {
        status { code toBe 301 }
        headers.getValue("some-custom-header") toBe "some-value"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.skrape.it/docs/http-client/pre-configure-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
