libcurl的用法参数太多 有时候弄不好 可以先用curl命令实现了 然后获取相应的libcurl代码

比如要上传文件

curl -T d:/h.txt http://demo.xudp.cn/up/

下面获取相应的代码

curl --libcurl d:/curl.txt -T d:/h.txt http://demo.xudp.cn/up/

相应的代码就放到d:/curl.txt里面了

/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h> int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd; hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t));
curl_easy_setopt(hnd, CURLOPT_URL, "http://demo.xudp.cn/up/h.txt");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.65.3");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
curl_easy_setopt(hnd, CURLOPT_HTTP09_ALLOWED, 1L);
curl_easy_setopt(hnd, CURLOPT_CAINFO, "C:\\Windows\\system32\\curl-ca-bundle.crt");
curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS, "C:\\Users\\Administrator\\AppData\\Roaming/_ssh/known_hosts");
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); /* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself. CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_INTERLEAVEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer */ ret = curl_easy_perform(hnd); curl_easy_cleanup(hnd);
hnd = NULL; return (int)ret;
}
/**** End of sample code ****/

从curl命令获取libcurl的用法的更多相关文章

  1. 使用curl命令获取文件下载速度

    使用curl可以下载网络内容,那如何获取curl下载时的下载速度呢,使用下面的命令即可: # curl -Lo /dev/null -skw "%{speed_download}\n&quo ...

  2. 记一次用Linux curl命令获取Django url返回值异常的问题

    问题描述: curl 检测 URL 返回值以判断服务器是否正常 原命令:curl -I -m 10 -o /dev/null -s -w %{http_code} --insecure $url 问题 ...

  3. Openstack Keystone V3 利用 curl 命令获取 token

    curl -i \ -H "Content-Type: application/json" \ -d ' { "auth": { "identity& ...

  4. cURL 命令获取本机外网 IP

    1.1 查询本机外网 IP # curl dhcp.cn 134.175.159.160 1.2 输出格式为 JSON # curl dhcp.cn/?json { "IP": & ...

  5. curl命令学习之一--基本用法

  6. zabbix通过curl命令判断web服务是否正常并自动重启服务

    zabbix通过curl命令判断web服务是否正常并自动重启服务 主要思路: 通过curl命令获取服务器响应码,如果正常返回200,不正常返回000 具体命令: curl -I -s -w " ...

  7. curl命令用法

    curl命令是一个功能强大的网络工具,它能够通过http.ftp等方式下载文件,也能够上传文件,同时支持HTTPS等众多协议,还支持POST.cookies.认证.从指定偏移处下载部分文件.用户代理字 ...

  8. curl命令常见用法汇总 good

    curl是一种命令行工具,作用是发出网络请求,然后得到和提取数据,显示在"标准输出"(stdout)上面. curl是一个强大的命令行工具,它可以通过网络将信息传递给服务器或者从服 ...

  9. curl命令的基本用法

    我们知道在linux环境下,可以调用curl下载网页. 但curl有些高级的应用,只需要几行命令行,可能比你写多行php.python.C++的程序要快些. 下面从问题驱动的角度来谈谈curl的用法 ...

随机推荐

  1. 关于页面多个ajax请求阻塞的问题

    最近遇到一个问题,我的一个页面有多个ajax请求,但是一个很快的请求却需要很长时间才返回,而且慢于一个耗时比较长的请求,我在考虑是不是有ajax异步并发有问题,但是查询了一些资料,ajax不存在这样的 ...

  2. textarea 限制输入字数

    一般情况下很多人限制textarea的输入字数会使用 onkeyup 或 onchange事件,但是这两种事件都带有明显的不足. onkeyup 事件只能监听键盘事件,而对于用户的粘贴毫无办法:而on ...

  3. python分别获取虚拟网卡和真实网卡ip

    #!/usr/bin/python # -*- coding: utf-8 -*- import commands import socket import fcntl import struct C ...

  4. mysql总结1

    修改表名:alter table table_name rename new_table_name; 添加字段:alter table table_name add column_name type_ ...

  5. PyCharm上unittest 测试用例两种执行方式

    每次讲到unittest测试框架的时候,经常有同学在群里反映,为啥我的运行不是按照我往suite里添加的用例顺序执行的,为什么别人的能跑出来报告,我的就不行... 当然,首先确认代码是OK的,如果代码 ...

  6. docker 安装 mxnet

    1.根据自己的需求安装mxnet:https://hub.docker.com/u/mxnet 2.拉取镜像: nvidia-docker pull mxnet/python:1.5.0_gpu_cu ...

  7. 用Ant实现Java项目的自动构建和部署(转载以作收藏)

    原文地址:http://tech.it168.com/j/2007-11-09/200711091344781.shtml        本文请勿转载! Ant是一个Apache基金会下的跨平台的构件 ...

  8. Sql service 分页存储过程

    create database Exam_Week3 GO USE Exam_Week3 GO create table Classs ( ClaID ,), ClassName ), Counts ...

  9. 高大上的微信小程序中渲染html内容—技术分享

    大部分Web应用的富文本内容都是以HTML字符串的形式存储的,通过HTML文档去展示HTML内容自然没有问题.但是,在微信小程序(下文简称为「小程序」)中,应当如何渲染这部分内容呢? 解决方案 wxP ...

  10. mysql常用查询命令

    转引自:https://www.cnblogs.com/widows/p/7137184.html 常用mysql命令 show variables like 'character_set_clien ...