CURLINFO_CONTENT_TYPE

CURL: Get Returned Content Mime Type

例如 :以下代码可以查询出天地图的tile图像类型为jpg

"http://t0.tianditu.com/img_c/wmts/wmts?Service=WMTS&Request=GetTile&Version=1.0.0&Style=Default&Format=tiles&serviceMode=KVP&layer=img&TileMatrixSet=c&TileMatrix=1&TileRow=0&TileCol=0"

        // Store the mime-type, if any. (Note: CURL manages the buffer returned by
        // this call.)
        char* ctbuf = NULL;
        if ( curl_easy_getinfo(_curl, CURLINFO_CONTENT_TYPE, &ctbuf) == 0 && ctbuf )
        {
            sp._resultMimeType = ctbuf;
        }

跟踪发现 ctbuf 为  "image/jpeg"

可参考 http://www.satya-weblog.com/2010/07/php-curl-get-returned-content-mime-type.html。 内容相同

05-11 23:02