---
title: Processor
summary: An ESI processor that can process a response containing ESI tags, dispatch requests for fragments, and process the fragment responses.
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/esi/class.Processor/
---

**Kind:** Class  
**Module:** [esi](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/esi/)  
**Package:** compute-sdk-cpp 0.7.0  
**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/esi.h#L78

Include `fastly/esi.h` to use this class.

An ESI processor that can process a response containing ESI tags, dispatch requests for fragments, and process the fragment responses.

## Constructor

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/esi.h#L81

```cpp
fastly::esi::Processor::Processor(std::optional<Request> original_request_metadata = std::nullopt, Configuration config = Configuration())
```

Create a new ESI processor with the given configuration.

**Parameters**

- `original_request_metadata`: `std::optional<Request>` (optional) = `std::nullopt`
- `config`: `Configuration` (optional) = `Configuration()`

## Methods

### process_document

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/esi.h#L111

```cpp
fastly::expected<std::string> fastly::esi::Processor::process_document(const std::string &src_document, std::optional<DispatchFragmentRequestFn> dispatch_fragment_request = std::nullopt, std::optional<ProcessFragmentResponseFn> process_fragment_response = std::nullopt)
```

Process a string containing ESI tags, optionally using the given callbacks to dispatch requests for fragments and process the fragment responses.

**Parameters**

- `src_document`: `const std::string &` — The string containing ESI tags to process.
- `dispatch_fragment_request`: `std::optional<DispatchFragmentRequestFn>` (optional) = `std::nullopt` — Optional callback to dispatch requests for fragments.
- `process_fragment_response`: `std::optional<ProcessFragmentResponseFn>` (optional) = `std::nullopt` — Optional callback to process fragment responses.

**Returns**

`fastly::expected<std::string>`

### process_response

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/esi.h#L95

```cpp
fastly::expected<void> fastly::esi::Processor::process_response(Response &src_document, std::optional<Response> client_response_metadata = std::nullopt, std::optional<DispatchFragmentRequestFn> dispatch_fragment_request = std::nullopt, std::optional<ProcessFragmentResponseFn> process_fragment_response = std::nullopt)
```

Process a response containing ESI tags, optionally using the given callbacks to dispatch requests for fragments and process the fragment responses.

**Parameters**

- `src_document`: `Response &` — The response containing ESI tags to process.
- `client_response_metadata`: `std::optional<Response>` (optional) = `std::nullopt` — Optional original client request data used for fragment requests.
- `dispatch_fragment_request`: `std::optional<DispatchFragmentRequestFn>` (optional) = `std::nullopt` — Optional callback to dispatch requests for fragments.
- `process_fragment_response`: `std::optional<ProcessFragmentResponseFn>` (optional) = `std::nullopt` — Optional callback to process fragment responses.

**Returns**

`fastly::expected<void>`
