HTTP 传输说明
本文描述 ss-server 当前暴露的 HTTP 传输层。
路由
POST /rpcGET /healthzPOST /upload/{resource_id}/{file_id}GET /download/{resource_id}/{file_id}
JSON-RPC
POST /rpc 需要完整的 JsonRpcRequestMessage JSON。
示例:
普通方法返回:
200 OKContent-Type: application/json- body 为完整
JsonRpcResponseMessage
流式响应
session.run_turn 仍然走 POST /rpc,但响应类型变为:
200 OKContent-Type: text/event-stream
事件规则:
- 第一个事件名固定为
ack - 后续事件名固定为
message
二进制上传与下载
二进制路由不使用 JSON-RPC。
- 上传 body 是原始字节
x-file-name是可选请求头- 缺失
Content-Type时先归一化为application/octet-stream
当前内置资源文件:
character:{character_id}/covercharacter:{character_id}/archivepackage_import:{import_id}/archivepackage_export:{export_id}/archive
POST /upload/{resource_id}/{file_id}
成功返回:
200 OKContent-Type: application/json- body 为
ResourceFilePayload
当前内置语义:
- 角色封面上传
.chr角色卡导入- 数据包 ZIP 上传到临时导入槽位
GET /download/{resource_id}/{file_id}
成功返回:
200 OK- body 为原始字节
Content-Type为逻辑文件类型
当前内置语义:
- 下载角色封面
- 导出
.chr - 下载准备好的数据包 ZIP
错误处理
/rpc解析失败:400 Bad Request+ErrorPayload- 二进制路由:
400 Bad Request404 Not Found409 Conflict500 Internal Server Error
客户端建议
- 普通
/rpc请求按 JSON 处理 session.run_turn使用支持text/event-stream的客户端/upload/...作为原始字节上传/download/...作为原始字节下载