0


postman请求设置

postman请求设置

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

在这里插入图片描述

2、请求头类型

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

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

  1. 1. Content-Type
  2. Content-Type 头字段用于告诉服务器(或客户端)请求或响应的主体数据的媒体类型(MIME 类型)。它指定了发送的数据的格式,以便接收方知道如何正确解析数据。
  3. 常见的 Content-Type 值:
  4. application/json:表示数据是 JSON 格式。
  5. http
  6. 复制代码
  7. Content-Type: application/json
  8. 示例请求体:
  9. json
  10. 复制代码
  11. {"name":"John",
  12. "age":30}
  13. application/x-www-form-urlencoded:表示数据是 URL 编码的表单数据,通常在表单提交时使用。
  14. http
  15. 复制代码
  16. Content-Type: application/x-www-form-urlencoded
  17. 示例请求体:
  18. makefile
  19. 复制代码
  20. name=John&age=30
  21. multipart/form-data:用于文件上传的表单数据,允许发送文件和键值对。
  22. http
  23. 复制代码
  24. Content-Type: multipart/form-data;boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
  25. text/plain:表示数据是纯文本格式。
  26. http
  27. 复制代码
  28. Content-Type: text/plain
  29. text/html:表示数据是 HTML 格式。
  30. http
  31. 复制代码
  32. Content-Type: text/html
  1. 2. Accept
  2. Accept 头字段用于告诉服务器,客户端希望接收到的响应内容的媒体类型。服务器会根据这个头字段来确定返回数据的格式,如果可能的话。
  3. 使用场景:
  4. 客户端发送请求时:客户端通过 Accept 头字段告诉服务器,它能够处理哪些格式的数据。服务器通常会根据这个信息决定返回什么类型的数据。如果服务器无法提供所请求的格式,可能会返回 406 Not Acceptable 状态码。
  5. 常见的 Accept 值:
  6. application/json:客户端希望接收到 JSON 格式的数据。
  7. http
  8. 复制代码
  9. Accept: application/json
  10. text/html:客户端希望接收到 HTML 格式的数据。
  11. http
  12. 复制代码
  13. Accept: text/html
  14. */*:客户端能够接受所有类型的数据。
  15. http
  16. 复制代码
  17. Accept: */*
  18. application/xml:客户端希望接收到 XML 格式的数据。
  19. http
  20. 复制代码
  21. Accept: application/xml

3、案例

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

  1. 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格式

  1. 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格式

  1. 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格式

  1. 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)
在这里插入图片描述

  1. import asyncio
  2. import aiohttp
  3. async def fetch_url(session, url):
  4. async with session.get(url) as response:
  5. status_code = response.status
  6. content = await response.text()return status_code, content[:500]# 只返回状态码和前100字符的响应内容
  7. async def main():
  8. url ="http://172.31.208.3:8077"
  9. async with aiohttp.ClientSession() as session:
  10. tasks =[fetch_url(session, url)for_in range(500)]
  11. results = await asyncio.gather(*tasks)for status_code, content in results:
  12. print(f"Status: {status_code}, Content: {content}")# 运行异步任务
  13. asyncio.run(main())

本文转载自: https://blog.csdn.net/weixin_44986037/article/details/141461155
版权归原作者 爱补鱼的猫猫 所有, 如有侵权,请联系我们删除。

“postman请求设置”的评论:

还没有评论