CURL_TIMECOND_NONE不起作用:如何删除 if-modified-from 标头



我使用libcurl来执行RTSP请求。我设置卷曲选项如下所示:

FILE *tmpListDownloadFile;
tmpListDownloadFile = fopen(tmp.c_str(), "w");
if(tmpListDownloadFile != NULL)
{
    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    char *p = curl_easy_unescape(curl, UriP, 0, NULL);
    string s = p;
    curl_free(p);
    string uri = url + "/?" + s;
    printf("%s uri:%sn",__FUNCTION__,uri.c_str());
    curl_version_info_data *d = curl_version_info(CURLVERSION_NOW);
    printf("curl version:%sn",d->version);
    curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, uri.c_str());
    curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, stRtspInfo.CSeq);
    curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, transport.c_str());
    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_SETUP);
    curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)tmpListDownloadFile);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15);
    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_NONE);
    CURLcode curlResult = curl_easy_perform(curl);
    char* session_id;
    if(curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &session_id) == CURLE_OK)
    {
        printf("%s session_id:%sn",__FUNCTION__, session_id);
        if(NULL != session_id)
        {
            ostringstream ss;
            ss << session_id;
            stRtspInfo.sessionID = ss.str();
            bIsSessionEstablished = true;
        }
    }
    else
    {
        printf("%s getting session id failedn",__FUNCTION__);
    }
    curl_easy_cleanup(curl);
    curl_global_cleanup();
    fclose(tmpListDownloadFile);
    if (curlResult == CURLE_OK && bIsSessionEstablished == true)
    {
        ...
    }
    else
    {
        printf("Setup failedn");
    }
}

日志消息如下。

RtspSetup url:rtsp://10.134.158.71
RtspSetup transport:RTP/AVP;unicast;client_port=45636-45637
RtspSetup uri:rtsp://10.134.158.71/?src=1&freq=11054&sr=30000&pol=v&msys=dvbs2&mtype=8psk&fec=34&ro=0.35&plts=off&pids=0
curl version:7.21.3
* About to connect() to 10.134.158.71 port 554 (#0)
*   Trying 10.134.158.71... * connected
* Connected to 10.134.158.71 (10.134.158.71) port 554 (#0)
> SETUP rtsp://10.134.158.71/?src=1&freq=11054&sr=30000&pol=v&msys=dvbs2&mtype=8psk&fec=34&ro=0.35&plts=off&pids=0 RTSP/1.0
CSeq: 1
Transport: RTP/AVP;unicast;client_port=45636-45637
If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT
* HTTP 1.1 or later with persistent connection, pipelining supported
< RTSP/1.0 200 OK
< CSeq: 1
< Date: Sat, Jan 01 2000 00:14:11 GMT
< Transport: RTP/AVP;unicast;destination=10.134.158.14;source=10.134.158.71;client_port=45636-45637;server_port=6970-6971
< Session: E3C33231;timeout=60
< com.ses.streamID: 3
< 
* Connection #0 to host 10.134.158.71 left intact
RtspSetup session_id:E3C33231

尽管我将Timecondition设置为none,但如果修改了,则会添加到标头中。如果自标题以来修改,我想删除。如何做到这一点?

这是libcurl中的一个错误(发生在某些RTSP请求中)。刚才在这个提交中修复了。将包含在即将发布的下一个版本中:7.46.0。

最新更新