How to upload a file in C/C++ using HTTP with libcurl? - c++

I would like to upload a file (a picture, in my case) in C/C++ using HTTP with libcurl.
It will be great to have a working sample in C/C++ with (optional) the php code for the server side.

Check out the tutorial at the libcurl site.

Related

HTTP web server cgi processing

I'm writing simple HTTP webserver in c++ for my college project and I want it to have CGI, so I can write some script in PHP or Perl. The question is: how to understand if I should call cgi program and grab its output, or simply give html page as response to a client. Only by a requested file's extension? I see no other options

Google API Client Library for C++ vs libcurl for sending HTTP request?

After installing google-api-client library for C++ on a Fedora 20 machine, I find out that it has external dependencies on libcurl (for example, setting up http proxy). I was planning to use google-api-client for sending HTTP request, mainly, HTTP multipart POST request. However, libcurl does provide support for multipart HTTP POST request also.
Could someone let me know the advantages of using Google API Client library for C++ over libcurl in order to send HTTP request?
Any suggestions/recommendations would be highly appreciated.
Thanks
The Google API Client Library is just a C++ wrapper around libcurl which is pure C library. I would use Casablanca REST SDK which is written in modern C++11, has no external dependencies and is cross platform.

Issue in getting custom header in Safari

I have a webservice which is hosted on api server and application on app server which have url's like https://webservice.test.com/ for webservice server and https://app.test.com/ for application.
In application we get live data from database using several service we developed on webservice server using CORS http request.
In some service like login we have passed custom header x-auth-token from server.
Above is the screen shot of response we have got in Google Chrome for the request. The Custom header shown in last is available in application when we use it in chrome or Mozilla. The same response we got in Safari too, x-auth-token also available in response when we check in headers but can't able to read it through code.
Finally, after a lot of search i got answer for my problem, Custom headers from CORS http request can be read only in Safari for latest webkit version i.e above 537. I have checked in all safari browser which is above this webkit version will provide me cusom header value. And similarly in chrome if webkit is less than 537 version you can't able to read it.
Maybe this answer on github could helpa bit : https://github.com/angular/angular.js/issues/6254

Plesk admin panel C/C++ API examples

I checked allover the internet to find any examples of ANSI C or C++ Plesk RPC API and I can find none. Any ideas? I just need to write a program that connects to my Plesk panel and enable/disable domain. Thanks!
XML-RPC don't dependence on language.
You need create valid xml and send to server (plesk https server 8443 port) recive her, and parse it. For example, you can to use opensource libs: libxml and curl.
Documentation XML-RPC http://download1.parallels.com/Plesk/PP11/11.0/Doc/en-US/online/plesk-api-rpc/
Also doc have C# example:
http://download1.parallels.com/Plesk/PP11/11.0/Doc/en-US/online/plesk-api-rpc/33182.htm

How to upload, download files in server side web serivce

How do I upload files in a REST web service? The Java Swing application will call REST web service to use the upload method.
I used apache.commons.fileupload but it is for web-based applications.
How do I download files? I used FileReader and PrintWriter. it is ok for other files, but I have a problem with pictures and zip files. What lib do I need to use to download binary files, pictures, zip, HTML, etc.?
https://stackoverflow.com/a/32253028/15789
For anyone who stumbles upon this page - the above may help. It is an example REST service that receives bytes of a file and sends zipped bytes in response. Using JAX-RS Client to send request and receive response.