# HTTP Request Skill

## Overview
You are an expert at making HTTP requests. Use this skill when users want to test APIs, debug webhooks, or interact with external services.

## Available Tools

### HTTP Operations
- `curl_exec` - Execute HTTP requests to any URL

### Related Tools
- `read_json_exec` - Parse JSON responses
- `read_markdown_exec` - Parse API documentation

## When to Use

### Active Triggers (User Explicitly Asks)
- "发送 HTTP 请求" / "make HTTP request"
- "测试 API" / "test API"
- "curl" / "wget"
- "调用接口" / "call endpoint"
- "POST/GET 请求" / "POST/GET request"
- "webhook" / "webhook 测试"
- "检查 API" / "check API"
- "请求调试" / "debug request"

### Passive Triggers (Tool Names)
- Tool `project_curl` called → activate this skill
- Tool `curl_exec` called → activate this skill

### Auto Triggers (Keywords)
- "http", "https", "api", "endpoint"
- "request", "response", "请求", "响应"
- "GET", "POST", "PUT", "DELETE", "PATCH"
- "header", "body", "参数"
- "webhook", "callback"
- "token", "bearer", "authorization"

## HTTP Request Guidelines

### 1. Request Construction
When making requests:
```
1. Identify the HTTP method
2. Construct the URL with query params
3. Add necessary headers
4. Prepare request body if needed
5. Handle authentication
```

### 2. Response Analysis
When analyzing responses:
```
1. Check status code
2. Parse response body
3. Identify errors
4. Note rate limits
5. Extract relevant data
```

### 3. Common Patterns
```
GET (Read):
- List resources
- No request body
- Query params for filtering

POST (Create):
- Create new resources
- JSON body
- Returns created resource

PUT (Update):
- Full resource update
- Complete JSON body
- Returns updated resource

PATCH (Partial Update):
- Partial update
- Only changed fields
- Returns updated resource

DELETE (Remove):
- Delete resource
- Usually no body
- Returns 204 or deleted resource
```

## Output Format

### Request Made
```
## HTTP Request

**Method:** [GET/POST/PUT/DELETE/PATCH]
**URL:** [full URL]
**Headers:**
- Content-Type: application/json
- Authorization: Bearer ***

**Body:**
```json
[request body]
```

**Response:**
- Status: [200 OK]
- Time: [N]ms

**Response Body:**
```json
[response body]
```
```

### API Test Result
```
## API Test: [Endpoint Name]

**Purpose:** [What this endpoint does]

**Request:**
```
[Method] [URL]
```

**Expected Response:**
- Status: [N]
- Body: [description]

**Actual Response:**
- Status: [N]
- Time: [N]ms
- Body: [summary]

**Result:** ✅ Pass / ❌ Fail

**Notes:**
- [Observations]
```

## Common HTTP Status Codes

### Success
- 200 OK - Request succeeded
- 201 Created - Resource created
- 204 No Content - Success, no body

### Client Errors
- 400 Bad Request - Invalid request
- 401 Unauthorized - Authentication needed
- 403 Forbidden - Permission denied
- 404 Not Found - Resource not found
- 422 Unprocessable - Validation error

### Server Errors
- 500 Internal Server Error
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout

## Best Practices
- Always check HTTPS
- Don't log sensitive headers
- Handle errors gracefully
- Respect rate limits
- Validate SSL certificates
- Use appropriate timeouts
