# SetRequestHeader(string, string)

> Set a HTTP request header to a custom value.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Networking](/engine/6000.0/script-reference/unityengine/networking.md)
* **Assembly:** UnityEngine.UnityWebRequestModule

```csharp
public void SetRequestHeader(string name, string value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The key of the header to be set. Case-sensitive.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The header's intended value.

### Remarks

Header keys and values must be valid according to HTTP protocol specification. Neither string may contain certain illegal characters, such as control characters. Both strings must be non-null and contain a minimum of 1 character. For more information, see [HTTP specifications](https://www.w3.orgProtocols).

This method can't be called after [UnityWebRequest.SendWebRequest](/engine/6000.0/script-reference/unityengine/networking/unitywebrequest/sendwebrequest.md) is called.

It is not recommended to set these headers to these custom values: `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`, `Access-Control-Request-Method`, `Connection`, `Date`, `Dnt`, `Expect`, `Host`, `Keep-Alive`, `Origin`, `Referer`, `Te`, `Trailer`, `Transfer-Encoding`, `Upgrade`, `Via`. Due to different limitations across platforms, the custom value might be overridden, ignored, or unsupported, therefore the resulting behavior is unreliable. It is strongly recommended to leave these headers for automatic handling unless you want to risk viewing any unexpected results.

The `Accept-Encoding` header is automatically set to supported encodings. Use of a different value is ignored or might cause request to fail. For more information, refer to the [Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) on Accept-Encoding.

The `Content-Length` header is automatically populated based on the contents of the attached [DownloadHandler](/engine/6000.0/script-reference/unityengine/networking/downloadhandler.md) if any, and can't be set to a custom value.

The `X-Unity-Version` header is automatically set by Unity and might not be set to a custom value.

The `User-Agent` header is automatically set by Unity and it's not recommended to set it to a custom value.

The `Cookie` and `Cookie2` headers are automatically managed by the underlying cookie engine. While the exact behavior is dependant on the platform used, typically, setting cookies via this header appends them to those set by engine. Additional Resources: [UnityWebRequest.ClearCookieCache](/engine/6000.0/script-reference/unityengine/networking/unitywebrequest/clearcookiecache.md).

In addition, the following headers are filled by the Web browser on the **Web** platform, and therefore might not have any custom values set: `Cookie`, `Cookie2`, `User-Agent`.
