postman请求设置

1、请求参数,只能是none、for-data、x-www…、raw等中的一个,不能多个。

在这里插入图片描述

2、请求头类型

根据请求头,选择参数,只能是none、for-data、x-www…、raw等中的一个,不能多个。

accept和Content-Type区别:
Content-Type:用于描述发送的数据的格式。
Accept:用于描述客户端希望接收的数据的格式。

1. Content-Type
Content-Type 头字段用于告诉服务器(或客户端)请求或响应的主体数据的媒体类型(MIME 类型)。它指定了发送的数据的格式,以便接收方知道如何正确解析数据。
常见的 Content-Type 值:
application/json:表示数据是 JSON 格式。

http
复制代码
Content-Type: application/json
示例请求体:

json
复制代码
{
  "name": "John",
  "age": 30
}
application/x-www-form-urlencoded:表示数据是 URL 编码的表单数据,通常在表单提交时使用。

http
复制代码
Content-Type: application/x-www-form-urlencoded
示例请求体:

makefile
复制代码
name=John&age=30
multipart/form-data:用于文件上传的表单数据,允许发送文件和键值对。

http
复制代码
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
text/plain:表示数据是纯文本格式。

http
复制代码
Content-Type: text/plain
text/html:表示数据是 HTML 格式。

http
复制代码
Content-Type: text/html
2. Accept
Accept 头字段用于告诉服务器,客户端希望接收到的响应内容的媒体类型。服务器会根据这个头字段来确定返回数据的格式,如果可能的话。

使用场景:
客户端发送请求时:客户端通过 Accept 头字段告诉服务器,它能够处理哪些格式的数据。服务器通常会根据这个信息决定返回什么类型的数据。如果服务器无法提供所请求的格式,可能会返回 406 Not Acceptable 状态码。
常见的 Accept 值:
application/json:客户端希望接收到 JSON 格式的数据。

http
复制代码
Accept: application/json
text/html:客户端希望接收到 HTML 格式的数据。

http
复制代码
Accept: text/html
*/*:客户端能够接受所有类型的数据。

http
复制代码
Accept: */*
application/xml:客户端希望接收到 XML 格式的数据。

http
复制代码
Accept: application/xml

3、案例

CosyVoice的一些请求
https://github.com/FunAudioLLM/CosyVoice
1.x-www-form-urlencoded格式

curl -X 'POST' \
  'http://172.31.208.3:50000/api/inference/sft' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'tts=%E5%B8%8C%E6%9C%9B%E4%BD%A0%E4%BB%A5%E5%90%8E%E8%83%BD%E5%A4%9F%E5%81%9A%E7%9A%84%E6%AF%94%E6%88%91%E8%BF%98%E5%A5%BD%E5%91%A6%E3%80%82&role=%E4%B8%AD%E6%96%87%E5%A5%B3'

在这里插入图片描述

在这里插入图片描述

2.form-data格式

curl -X 'POST' \
  'http://172.31.208.3:50000/api/inference/zero-shot' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'tts=没有什么能够阻挡,你对自由的向往,天马行空的生涯,你的心了无牵挂' \
  -F 'prompt=我做的装置可不是骗人的。想瞒着外面的人解决这场灾难,就必须用到它。只不过,那个装置不是为你准备的罢了。' \
  -F 'audio=@vo_LLZAQ001_12_dottore_06.wav;type=audio/wav'

在这里插入图片描述

在这里插入图片描述
3.form-data格式

curl -X 'POST' \
  'http://172.31.208.3:50000/api/inference/cross-lingual' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'tts=没有什么能够阻挡,你对自由的向往,天马行空的生涯,你的心了无牵挂' \
  -F 'audio=@vo_LLZAQ001_12_dottore_06.wav;type=audio/wav'

在这里插入图片描述

在这里插入图片描述

4.x-www-form-urlencoded格式

curl -X 'POST' \
  'http://172.31.208.3:50000/api/inference/instruct' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'tts=%E6%B2%A1%E6%9C%89%E4%BB%80%E4%B9%88%E8%83%BD%E5%A4%9F%E9%98%BB%E6%8C%A1%2C%E4%BD%A0%E5%AF%B9%E8%87%AA%E7%94%B1%E7%9A%84%E5%90%91%E5%BE%80%2C%E5%A4%A9%E9%A9%AC%E8%A1%8C%E7%A9%BA%E7%9A%84%E7%94%9F%E6%B6%AF%2C%E4%BD%A0%E7%9A%84%E5%BF%83%E4%BA%86%E6%97%A0%E7%89%B5%E6%8C%82&role=%E4%B8%AD%E6%96%87%E5%A5%B3&instruct=%3Claughter%3E%3C%2Flaughter%3E'

在这里插入图片描述

在这里插入图片描述

4、测压

这个Runner是串行测试,不是并行,别被网上的教程误导了。

可以用python脚本实现并行:
在Python中,如果你想并行发送多个请求到同一个接口,可以使用以下几种方法:
线程池 (concurrent.futures.ThreadPoolExecutor)
进程池 (concurrent.futures.ProcessPoolExecutor)
异步IO (asyncio + aiohttp)
在这里插入图片描述

import asyncio
import aiohttp

async def fetch_url(session, url):
    async with session.get(url) as response:
        status_code = response.status
        content = await response.text()
        return status_code, content[:500]  # 只返回状态码和前100字符的响应内容

async def main():
    url = "http://172.31.208.3:8077"
    async with aiohttp.ClientSession() as session:
        tasks = [fetch_url(session, url) for _ in range(500)]
        results = await asyncio.gather(*tasks)
        for status_code, content in results:
            print(f"Status: {status_code}, Content: {content}")

# 运行异步任务
asyncio.run(main())
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值