# RequestHeadersTransformExtensions Methods

- Package: [Aspire.Hosting.Yarp](/reference/api/csharp/aspire.hosting.yarp.md)
- Type: [RequestHeadersTransformExtensions](/reference/api/csharp/aspire.hosting.yarp/requestheaderstransformextensions.md)
- Kind: `Methods`
- Members: `6`

Extensions for adding request header transforms.

## WithTransformCopyRequestHeaders(YarpRoute, bool)

- Name: `WithTransformCopyRequestHeaders(YarpRoute, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L19-L20)

Adds the transform which will enable or suppress copying request headers to the proxy request.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformCopyRequestHeaders(
        this YarpRoute route,
        bool copy = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `copy` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformRequestHeader(YarpRoute, string, string, bool)

- Name: `WithTransformRequestHeader(YarpRoute, string, string, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L39-L40)

Adds the transform which will append or set the request header.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformRequestHeader(
        this YarpRoute route,
        string headerName,
        string value,
        bool append = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `value` (`string`)
- `append` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformRequestHeaderRemove(YarpRoute, string)

- Name: `WithTransformRequestHeaderRemove(YarpRoute, string)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L59-L60)

Adds the transform which will remove the request header.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformRequestHeaderRemove(
        this YarpRoute route,
        string headerName)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformRequestHeaderRouteValue(YarpRoute, string, string, bool)

- Name: `WithTransformRequestHeaderRouteValue(YarpRoute, string, string, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L49-L50)

Adds the transform which will append or set the request header from a route value.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformRequestHeaderRouteValue(
        this YarpRoute route,
        string headerName,
        string routeValueKey,
        bool append = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `routeValueKey` (`string`)
- `append` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformRequestHeadersAllowed(YarpRoute, string[])

- Name: `WithTransformRequestHeadersAllowed(YarpRoute, string[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L70-L71)

Adds the transform which will only copy the allowed request headers. Other transforms that modify or append to existing headers may be affected if not included in the allow list.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformRequestHeadersAllowed(
        this YarpRoute route,
        params string[] allowedHeaders)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `allowedHeaders` (`string[]`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformUseOriginalHostHeader(YarpRoute, bool)

- Name: `WithTransformUseOriginalHostHeader(YarpRoute, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs#L29-L30)

Adds the transform which will copy the incoming request Host header to the proxy request.

```csharp
public static class RequestHeadersTransformExtensions
{
    public static YarpRoute WithTransformUseOriginalHostHeader(
        this YarpRoute route,
        bool useOriginal = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `useOriginal` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
