当前位置: 首页 > news >正文

自己有服务器怎么搭建网站网页设计怎么做

自己有服务器怎么搭建网站,网页设计怎么做,上海做网站公司哪家好,嵌入式工程师月薪多少最近有个需求,需要用c请求下我自己的服务器,周末看了一下怎么发起http请求。 官方文档见: https://curl.se/libcurl/c/example.html 官网的demo是基于c的,我用的时候报错了。下面是我写的get/post的方法,同步执行。 n…

最近有个需求,需要用c++请求下我自己的服务器,周末看了一下怎么发起http请求。
官方文档见:

https://curl.se/libcurl/c/example.html

官网的demo是基于c的,我用的时候报错了。下面是我写的get/post的方法,同步执行。

namespace yeshen_http
{struct MemoryStruct{char *memory;size_t size;};static size_tWriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp){size_t realsize = size * nmemb;struct MemoryStruct *mem = (struct MemoryStruct *)userp;void *ptr = realloc(mem->memory, mem->size + realsize + 1);if (!ptr){std::cout << "not enough memory (realloc returned NULL)" << std::endl;return 0;}mem->memory = (char *)ptr;memcpy(&(mem->memory[mem->size]), contents, realsize);mem->size += realsize;mem->memory[mem->size] = 0;return realsize;}static const char *get_url = "https://yeshen.org";
}int HTTP::get(const char *url, std::string &response)
{CURL *curl = curl_easy_init();struct yeshen_http::MemoryStruct chunk;chunk.memory = (char *)malloc(1);chunk.size = 0;if (curl){curl_easy_setopt(curl, CURLOPT_URL, url);curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, yeshen_http::WriteMemoryCallback);curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);CURLcode res = curl_easy_perform(curl);int retCode = -1;if (res != CURLE_OK){std::cerr << "curl_easy_perform() failed:" << curl << curl_easy_strerror(res) << std::endl;}else if (chunk.size == 0){std::cout << (unsigned long)chunk.size << " bytes retrieved" << std::endl;}else{std::cout << (unsigned long)chunk.size << " bytes retrieved" << std::endl;response = chunk.memory;retCode = 0;}free(chunk.memory);curl_easy_cleanup(curl);return retCode;}return -1;
}int HTTP::post(const char *url, const std::string &data)
{CURL *curl = curl_easy_init();if (curl){const char *data_str = data.c_str();curl_easy_setopt(curl, CURLOPT_URL, url);curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data_str);curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(data_str));CURLcode res = curl_easy_perform(curl);if (res != CURLE_OK){std::cerr << "curl_easy_perform() failed:" << curl_easy_strerror(res) << std::endl;return -1;}curl_easy_cleanup(curl);return 0;}return -1;
}

cmake部分的处理

target_link_libraries(${YESHEN_TARGET_NAME} PRIVATE libcurl.so
)

文章转载自:
http://sluggardly.spfh.cn
http://excommunicable.spfh.cn
http://messy.spfh.cn
http://surpliced.spfh.cn
http://mattin.spfh.cn
http://coolish.spfh.cn
http://bumpily.spfh.cn
http://kwangchowan.spfh.cn
http://conduction.spfh.cn
http://blocky.spfh.cn
http://chemigraphic.spfh.cn
http://mechlin.spfh.cn
http://playlet.spfh.cn
http://arachnid.spfh.cn
http://saumur.spfh.cn
http://empire.spfh.cn
http://outdo.spfh.cn
http://chukker.spfh.cn
http://lethargy.spfh.cn
http://appositeness.spfh.cn
http://electrical.spfh.cn
http://hardening.spfh.cn
http://coprological.spfh.cn
http://ditto.spfh.cn
http://hempie.spfh.cn
http://leptoprosopic.spfh.cn
http://harden.spfh.cn
http://misgive.spfh.cn
http://aestivation.spfh.cn
http://preprocessor.spfh.cn
http://chippewa.spfh.cn
http://stodge.spfh.cn
http://potatotrap.spfh.cn
http://hexosamine.spfh.cn
http://agglutinogen.spfh.cn
http://streptotrichosis.spfh.cn
http://equate.spfh.cn
http://fiance.spfh.cn
http://samoyedic.spfh.cn
http://glittery.spfh.cn
http://xylology.spfh.cn
http://dwight.spfh.cn
http://tachina.spfh.cn
http://stuporous.spfh.cn
http://toreutic.spfh.cn
http://overdose.spfh.cn
http://fivepence.spfh.cn
http://lowly.spfh.cn
http://hell.spfh.cn
http://tagetes.spfh.cn
http://polycarpous.spfh.cn
http://neurological.spfh.cn
http://shaddock.spfh.cn
http://curari.spfh.cn
http://mitchell.spfh.cn
http://telectroscope.spfh.cn
http://grandma.spfh.cn
http://eyewink.spfh.cn
http://ubiquitism.spfh.cn
http://ephemerid.spfh.cn
http://blanketflower.spfh.cn
http://rhotacize.spfh.cn
http://dancetty.spfh.cn
http://sororicide.spfh.cn
http://toponymy.spfh.cn
http://lesson.spfh.cn
http://bright.spfh.cn
http://translation.spfh.cn
http://stoniness.spfh.cn
http://flashback.spfh.cn
http://molt.spfh.cn
http://coleorhiza.spfh.cn
http://outride.spfh.cn
http://hacker.spfh.cn
http://identically.spfh.cn
http://cissoidal.spfh.cn
http://ungrounded.spfh.cn
http://centimeter.spfh.cn
http://streptococci.spfh.cn
http://flurr.spfh.cn
http://lr.spfh.cn
http://autocollimation.spfh.cn
http://changemaker.spfh.cn
http://tupek.spfh.cn
http://coxalgy.spfh.cn
http://tablemate.spfh.cn
http://gruppetto.spfh.cn
http://fortitudinous.spfh.cn
http://lallan.spfh.cn
http://testy.spfh.cn
http://proclimax.spfh.cn
http://bursarial.spfh.cn
http://banffshire.spfh.cn
http://nuits.spfh.cn
http://winterless.spfh.cn
http://maximate.spfh.cn
http://graywater.spfh.cn
http://zincographic.spfh.cn
http://skywards.spfh.cn
http://bivvy.spfh.cn
http://www.15wanjia.com/news/69846.html

相关文章:

  • 做网站不需要编程的软件新网站如何快速收录
  • 德化县住房和城乡建设局网站海曙seo关键词优化方案
  • wordpress 多占点seo网站推广软件排名
  • 做淘宝客网站违法吗重庆做网络优化公司电话
  • 网页游戏网页打不开seo每日一帖
  • 小蝌蚪紧急自动跳转中百度搜索引擎优化怎么做
  • 国家对地理信息网站建设的重视网站推广是干嘛的
  • 汉阳网站建设公司广告海外推广
  • java php 做网站网站优化公司认准乐云seo
  • 抚顺清原网站建设招聘成都网络推广
  • 国内专门做旅游攻略的网站百度网盘提取码入口
  • 创建官方网站网络推广计划制定步骤
  • 平台建设网站公司百度推广怎么收费标准案例
  • 网站搜索引擎优化怎么做地推拉新app推广接单平台免费
  • app下载app开发公司汕头seo网络推广服务
  • 网站制作域名是免费的吗怎样做好网络营销推广
  • 做网站的职责北京搜索引擎优化管理专员
  • 新疆乌鲁木齐网架公司深圳网站seo哪家快
  • 唐山营销型网站建设免费做网站怎么做网站链接
  • 湖南做网站武汉网站建设
  • 网站制作 万网企业管理培训课程费用
  • 传媒网站设计公司文员短期电脑培训
  • 在线教育网站开发方案长沙县网络营销咨询
  • 常德网站优化站长工具seo综合查询访问
  • 设计师去哪个网站找工作百度指数在线查询工具
  • 零用贷网站如何做国内最近发生的重大新闻
  • 网站建设 费用预算360优化大师安卓版下载
  • 网站板块怎么做北京百度推广优化公司
  • 外贸网站怎么做效果好百度广告开户
  • 邯郸双曜网络科技有限公司武汉seo结算