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

# HttpClient / HttpResponse

> 脚本同步 HTTP

<Warning>
  同步阻塞。不要在 `tick` / `render_2d` 里直接调，要走 `me.async("method")`。
</Warning>

## HttpClient

```java theme={null}
HttpResponse HttpClient.get(String url)
HttpResponse HttpClient.get(String url, Map<String,String> headers)

byte[] HttpClient.getBytes(String url)                          // 二进制 GET
byte[] HttpClient.getBytes(String url, Map<String,String> headers)

HttpResponse HttpClient.post(String url, String body)
HttpResponse HttpClient.post(String url, String body, Map<String,String> headers)
HttpResponse HttpClient.postJson(String url, String jsonBody)

HttpResponse HttpClient.put(String url, String body)
HttpResponse HttpClient.put(String url, String body, Map<String,String> headers)
HttpResponse HttpClient.delete(String url)
HttpResponse HttpClient.delete(String url, Map<String,String> headers)

HttpResponse HttpClient.request(String method, String url, String body, Map<String,String> headers)
HttpResponse HttpClient.request(String method, String url, String body, Map<String,String> headers,
                                int connectSec, int requestSec)
```

## HttpResponse

```java theme={null}
int     statusCode / getStatusCode()
String  body       / getBody()
Map<String, List<String>>  headers / getHeaders()
String  error      / getError()          // 非 null 表示网络层失败

boolean isOk()                           // 2xx
boolean isError()                        // 失败或 -1
String  header(String name)              // 大小写不敏感
```
