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

# 请求头

> Site Unblocker 请求头

## 传递请求头

通过 Site Unblocker 发送的请求头将直接传递到目标网站。

<CodeGroup>
  ```shellscript cURL theme={null}
  curl -k -v -x unblock.decodo.com:60000 \
       -U "USERNAME:PASSWORD" "https://ip.decodo.com/" \
       -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36"
       -H "X-Foo: Bar" \ 
  ```

  ```python Python theme={null}
  import requests

  proxies = {
      'http': 'http://USERNAME:PASSWORD@unblock.decodo.com:60000',
      'https': 'http://USERNAME:PASSWORD@unblock.decodo.com:60000'
  }

  headers= {
      'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36'
      'X-Foo': 'Bar',
  }

  response = requests.request(
      'GET',
      'https://ip.decodo.com/',
      verify=False,
      proxies=proxies,
      headers=headers
  )

  print(response.text)
  ```

  ```javascript Node.js theme={null}
  import fetch from 'node-fetch';
  import createHttpsProxyAgent from 'https-proxy-agent'

  const username = 'YOUR_USERNAME';
  const password = 'YOUR_PASSWORD';

  const agent = createHttpsProxyAgent(
    `http://${username}:${password}@unblock.decodo.com:60000`
  );

  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

  const headers = {
      'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36'
      'X-Foo': 'Bar',
  }

  const response = await fetch('https://ip.decodo.com/', {
    method: 'get',
    headers: headers,
    agent: agent
  });

  console.log(await response.text());
  ```
</CodeGroup>

### 例外情况

以下请求头会被 Site Unblocker 拦截，默认情况下不会转发到目标网站：

* `host`
* `accept`
* `connection`
* `cache-control`

如果您希望将这些请求头传递到目标网站，请在请求头的键前添加 `X-SU-Custom-` 前缀：

<CodeGroup>
  ```shellscript cURL theme={null}
  curl -k -v -x unblock.decodo.com:60000 \
       -U "USERNAME:PASSWORD" "https://ip.decodo.com/" \
       -H `X-SU-Custom-Host: spoofed.website.com:8080`
       -H "X-Foo: Bar" \ 
  ```
</CodeGroup>

## Cookies

`Cookie` 请求头不需要任何前缀，可以直接传递：

<CodeGroup>
  ```shellscript cURL theme={null}
  curl -k -v -x unblock.decodo.com:60000 \
       -U "USERNAME:PASSWORD" "https://ip.decodo.com/" \
       -H "Cookie: abc=4206969; def=1234567"
  ```

  ```python Python theme={null}
  import requests

  proxies = {
      'http': 'http://USERNAME:PASSWORD@unblock.decodo.com:60000',
      'https': 'http://USERNAME:PASSWORD@unblock.decodo.com:60000'
  }

  headers= {
      'Cookie': 'abc=4206969; def=1234567',
    	'X-SU-Force-Cookies: 1',
  }

  response = requests.request(
      'GET',
      'https://ip.decodo.com/',
      verify=False,
      proxies=proxies,
      headers=headers
  )

  print(response.text)
  ```

  ```javascript Node.js theme={null}
  import fetch from 'node-fetch';
  import createHttpsProxyAgent from 'https-proxy-agent'

  const username = 'YOUR_USERNAME';
  const password = 'YOUR_PASSWORD';

  const agent = createHttpsProxyAgent(
    `http://${username}:${password}@unblock.decodo.com:60000`
  );

  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

  const headers = {
    'Cookie': 'abc=4206969; def=1234567',
    'X-SU-Force-Cookies: 1',
  }

  const response = await fetch('https://ip.decodo.com/', {
    method: 'get',
    headers: headers,
    agent: agent
  });

  console.log(await response.text());
  ```
</CodeGroup>

# 强制请求头

Site Unblocker 使用预定义的请求头和 cookie 组合来实现目标网站的最高成功率。这意味着，有时我们可能需要丢弃客户提供的请求头以提高成功率。

但是，可以通过强制请求头或 cookies 来覆盖此行为。

<Warning>
  强制使用请求头或 cookies 时，即使请求失败，也会从您的订阅中扣费。
</Warning>

| 请求头                  | 有效值 | 描述                 |
| -------------------- | --- | ------------------ |
| `X-SU-Force-Headers` | `1` | 强制将所有请求头转发到目标。     |
| `X-SU-Force-Cookies` | `1` | 强制将 `Cookie` 转发到目标 |

***

<Columns cols={2}>
  <Card title="支持" href="https://direct.lc.chat/12092754" cta="让我们聊聊！">
    需要帮助或只是想打个招呼？我们的支持团队全天候为您服务。 \
    您也可以随时通过电子邮件 [support@decodo.com](mailto:support@decodo.com) 联系我们。
  </Card>

  <Card title="反馈" href="mailto:feedback@decodo.com" cta="分享反馈">
    找不到您要找的内容？请求一篇文章！ \
    有反馈意见？分享您对我们如何改进的想法。
  </Card>
</Columns>
