> ## Documentation Index
> Fetch the complete documentation index at: https://klef.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ConnectorHttp

> Builds the HTTP pipeline for vendor calls.

```csharp
public static class ConnectorHttp
```

## Fields

**ReadAttempts** `int` *required*

How many times a read is tried.

**TelemetrySource** `string` *required*

The trace source of every vendor call.

## Methods

### Allows()

```csharp
public static bool Allows(ConnectorManifest manifest, string host, IReadOnlyDictionary<string, string?>? settings)
```

Whether the egress list allows a host.

#### Parameters

**manifest** `ConnectorManifest` *required*

**host** `string` *required*

**settings** `IReadOnlyDictionary\<string, string\>` *required*

The connection's values, which fill the list's templates.

#### Returns

`bool`

### AsCreate()

```csharp
public static HttpRequestMessage AsCreate(this HttpRequestMessage request, string objectKey)
```

Marks a request as creating an object, so a conflict means one already exists.

#### Parameters

**request** `HttpRequestMessage` *required*

The request.

**objectKey** `string` *required*

The manifest object's key.

#### Returns

`HttpRequestMessage`

### AsObject()

```csharp
public static HttpRequestMessage AsObject(this HttpRequestMessage request, string objectKey, string? id)
```

Marks a request as addressing one object, so a not found means that object is gone.

#### Parameters

**request** `HttpRequestMessage` *required*

The request.

**objectKey** `string` *required*

The manifest object's key.

**id** `string` *required*

The vendor's id for the object, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the caller names it on the failure.

#### Returns

`HttpRequestMessage`

### AsRead()

```csharp
public static HttpRequestMessage AsRead(this HttpRequestMessage request)
```

Marks a request as a read.

#### Parameters

**request** `HttpRequestMessage` *required*

#### Returns

`HttpRequestMessage`

### AuthHeadersAsync()

```csharp
public static Task<IReadOnlyDictionary<string, string>> AuthHeadersAsync(AuthManifest auth, ITokenStore tokens, IReadOnlyDictionary<string, string?>? settings, CancellationToken cancellationToken)
```

The headers the manifest's auth puts on a request, for a connector in another process.

#### Parameters

**auth** `AuthManifest` *required*

**tokens** `ITokenStore` *required*

**settings** `IReadOnlyDictionary\<string, string\>` *required*

**cancellationToken** `CancellationToken` *required*

#### Returns

`Task<IReadOnlyDictionary<string, string>>`

### Context()

```csharp
public static ConnectionContext Context(ConnectorManifest manifest, string connection, HttpMessageHandler handler, ITokenStore tokens, ILogger logger, ReadCache readCache, IReadOnlyDictionary<string, string?>? settings = null, IReadOnlyDictionary<string, string?>? installation = null, IConnectionState? stored = null, Uri? baseAddress = null, VendorLimits? limits = null, TimeSpan? longestThrottleWait = null)
```

Builds a context for one connection.

#### Parameters

**manifest** `ConnectorManifest` *required*

**connection** `string` *required*

**handler** `HttpMessageHandler` *required*

**tokens** `ITokenStore` *required*

**logger** `ILogger` *required*

**readCache** `ReadCache` *required*

**settings** `IReadOnlyDictionary\<string, string\>`

**installation** `IReadOnlyDictionary\<string, string\>`

**stored** `IConnectionState`

**baseAddress** `Uri`

Where to send the calls instead of the vendor. The installation's `base_url` when not given.

**limits** `VendorLimits`

**longestThrottleWait** `TimeSpan?`

#### Returns

`ConnectionContext`

### Create()

```csharp
public static HttpClient Create(HttpMessageHandler transport, AuthManifest auth, ITokenStore tokens, IReadOnlyDictionary<string, string?>? settings = null)
```

Creates a client applying the manifest's auth.

#### Parameters

**transport** `HttpMessageHandler` *required*

**auth** `AuthManifest` *required*

**tokens** `ITokenStore` *required*

**settings** `IReadOnlyDictionary\<string, string\>`

#### Returns

`HttpClient`

```csharp
public static HttpClient Create(HttpMessageHandler transport, ITokenStore tokens)
```

Creates a client sending bearer tokens.

#### Parameters

**transport** `HttpMessageHandler` *required*

**tokens** `ITokenStore` *required*

#### Returns

`HttpClient`

### DefaultKind()

```csharp
public static FailureKind DefaultKind(HttpStatusCode status, bool notFoundIsGone = false, bool conflictExists = false)
```

Gets the failure kind a status means.

#### Parameters

**status** `HttpStatusCode` *required*

**notFoundIsGone** `bool`

**conflictExists** `bool`

#### Returns

`FailureKind`

### IsRead()

```csharp
public static bool IsRead(this HttpRequestMessage request)
```

Whether a request only reads.

#### Parameters

**request** `HttpRequestMessage` *required*

#### Returns

`bool`

### ReadAsync()

```csharp
public static Task<T> ReadAsync<T>(this HttpResponseMessage response, JsonSerializerOptions options, CancellationToken cancellationToken) where T : notnull
```

Reads a response's JSON body.

#### Type Parameters

**T** *required*

#### Parameters

**response** `HttpResponseMessage` *required*

**options** `JsonSerializerOptions` *required*

**cancellationToken** `CancellationToken` *required*

#### Returns

`Task<T>`

### Transport()

```csharp
public static HttpMessageHandler Transport(HttpMessageHandler handler, ConnectorManifest manifest, Uri? baseAddress = null, TimeSpan? timeout = null, IReadOnlyDictionary<string, string?>? settings = null, string? connection = null, VendorLimits? limits = null, TimeSpan? longestThrottleWait = null)
```

Builds the pipeline without auth.

#### Parameters

**handler** `HttpMessageHandler` *required*

**manifest** `ConnectorManifest` *required*

**baseAddress** `Uri`

**timeout** `TimeSpan?`

**settings** `IReadOnlyDictionary\<string, string\>`

**connection** `string`

**limits** `VendorLimits`

**longestThrottleWait** `TimeSpan?`

How long a call waits out a throttle before it fails as [Throttled](https://klef.ai/docs/connector-sdk/reference/model/failurekind.md). Five seconds when not given.

#### Returns

`HttpMessageHandler`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.