gpt4 book ai didi

ruby - 使用 Ruby curl 检索完整的请求字符串

转载 作者:数据小太阳 更新时间:2023-10-29 07:19:22 26 4
gpt4 key购买 nike

我打算发送如下请求:

c = Curl::Easy.http_post("https://example.com", json_string   
) do |curl|
curl.headers['Accept'] = 'application/json'
curl.headers['Content-Type'] = 'application/json'
curl.headers['Api-Version'] = '2.2'
end

我想记录正在发出的确切 http 请求。有没有办法获取发出的实际请求(基本路径、查询参数、 header 和正文)?

最佳答案

on_debug handler以前帮助过我。在您的示例中,您可以尝试:

curl.on_debug do |type, data|
puts type, data
end

关于ruby - 使用 Ruby curl 检索完整的请求字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14345293/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com