gpt4 book ai didi

c++ - 带有 header 的发布请求中出现错误 411(需要长度),但 header 具有 Content-Length。库 curl

转载 作者:太空狗 更新时间:2023-10-29 21:28:18 24 4
gpt4 key购买 nike

我使用这个选项:

curl_easy_setopt(curl, CURLOPT_URL, urlUpload); 
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);

必须是带有header的post请求。在 header 变量中有长度

***
char sizeStr[50];
sprintf(sizeStr, "Content-Length: %d", body.length());

***

header = curl_slist_append(header, sizeStr);

***

我想做的是将视频上传到 YouTube,我正在使用 their manual

我收到这样的错误。

<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<title>Error 411 (Length Required)!!1</title>
<style>
*many symbols here*
</style>
<a href=//www.google.com/ id=g><img src=//www.google.com/images/logo_sm.gif alt=Google></a>
<p><b>411.</b> <ins>Thatв€™s an error.</ins>
<p>POST requests require a <code>Content-length</code> header. <ins>Thatв€™s all we know.</ins>

也许我必须使用其他一些 CURLoptions?

更新:当我设置

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

我也收到了

* About to connect() to uploads.gdata.youtube.com port 80 (#0)
* Trying 74.125.XX.XXX... * connected
* Connected to uploads.gdata.youtube.com (74.125.XX.XXX) port 80 (#0)
> POST /feeds/api/users/default/uploads HTTP/1.1

Accept: */*

Host: uploads.gdata.youtube.com

Authorization: GoogleLogin auth=DQAAAIkAAACTK9tZPCTY1XQvXGkg4qkaIuZ1QO-Bh6- ZyzOHuigFNC_gR4Piep4NljAjdOP4s-k7vqj-j4LdckXM9jxzlElgtaxr- CShI1vIWkjm5ZtFsj3a9v1YqFmjIkEi3NCP2ON18D9jmXSIarPqprWiOK0n3oxznCBhm4osXwJ1yRstVVM5bG5mOlC331eMCrOKp3E


GData-Version: 2

X-GData-Key: key=AI39si59VMkm6DATDmfG_Df6D23jfto3xRVfbAEMrFBv035pdRZ5AYMPsRXbGLCRXXnK5jz6KCSWSkuXOTrlDIIKWy7Le9fkQQ

Slug: screen.avi

Content-Type: multipart/related; boundary="d31fcjR2"

Content-length: 910273

Connection: close


* HTTP 1.0, assume close after body
< HTTP/1.0 411 Length Required

< Content-Type: text/html; charset=UTF-8

< Content-Length: 11791

< Date: Fri, 02 Sep 2011 16:09:58 GMT

< Server: GFE/2.0

<

* Closing connection #0

最佳答案

这个错误是因为在我从 YouTube 收到的身份验证字符串中最后是换行符号,我将其删除,这个错误就消失了。

关于c++ - 带有 header 的发布请求中出现错误 411(需要长度),但 header 具有 Content-Length。库 curl ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7285325/

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