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

# icon/getIconContent

> `getIconContent`函数主要是用来在响应中获取icon地址，然后访问这个icon获取其字节流数据

## 函数原型

`func (r1 response) getIconContent() bytes`

### 参数介绍

| 参数名称 | 参数介绍 |
| ---- | ---- |
| r1   | 响应包  |

## 举例

* 该函数会对响应包中的icon数据进行进行匹配解码，并返回icon的字节流数据。
* 如果响应包中不存在icon数据，则会查找是否存在记录了相关icon链接的内容，如果存在，则会尝试访问该链接，并获取icon的字节流数据
* 如果还是没有找到icon的信息，则会访问`/favicon.ico`尝试获取icon的字节流数据
* 该函数一般搭配`faviconHash()`一同使用，具体示例如下，测试地址为`https://docs.xray.cool`

<CodeGroup>
  ```yaml icon theme={null}
  name: poc-yaml-test
  transport: http
  rules:
    r0:
      request:
        method: GET
        path: /
        follow_redirects: false
      expression: response.status == 200 && faviconHash(response.icon()) == 938617678
  expression: r0()
  detail:
    author: test
    links:
      - test
  ```

  ```yaml getIconContent theme={null}
  name: poc-yaml-test
  transport: http
  rules:
    r0:
      request:
        method: GET
        path: /
        follow_redirects: false
      expression: response.status == 200 && faviconHash(response.getIconContent()) == 938617678
  expression: r0()
  detail:
    author: test
    links:
      - test
  ```
</CodeGroup>
