logging in libcurl - libcurl

How to modify libcurl so that all the error descriptions are collected in a common log file ?
I am trying to port libcurl to android and display curl logs on adb. Is there a way to log all the activities of libcurl ?

How about simply using CURLOPT_DEBUGFUNCTION? It was designed for exactly such a purpose...

Related

CURL ERROR DOWNLOAD : Recv failure : Connection was reset (using c++)

I have a console application using C++
This application only serves to download files from the central server to the client
I use curl to api the download.
but there is a problem from the client environment side
in the dev environment it is successful
currently only using http to download it.
Here's a screenshot of the console app.
there is an error Recv failure: Connection was reset
Please help
thanks
screenshot error application

How to avoid QNetworkRequest to send the RHELP verb to the FTP Server?

The Scenario:
I'm implementing an FTP get functionality in my application, that uses Qt 4.7.x
Qt documentation states that the QFtp class is deprecated, to use QNetworkAccessManager instead, and so I'm doing ;) I tested the code I wrote with some FTP server out there and it seems to work fine.
The Problem:
When I connect to my local, homebrewed (and quite simple), ftp server using my ftp get class I get the following error: Request: 500 No Help Available.
I traced the ftp communication using tcpdump and actually I see that the QNetworkAccessManager/QNetworkRequest sends an HELP verb to the server, once it gets the 230 User Logged In
Unfortunately my server do not support that. Now is there a way to configure the Qt not to send the HELP verb? Reading the Qt Doc online for the involved classes did not helped.
There is probably no way to avoid this, unless you want to reimplement the FTP backend. By browsing the source code for the FTP backend, you can find out that the purpose for sending the HELP command is to find out if the server supports the "SIZE" and "MDTM" commands.
Probably the easiest solution would be to implement a minimal handler for HELP commands in your FTP server that responds with an appropriate 200/211/214 response.
EDIT: See http://qt.gitorious.org/qt/qt/blobs/4.8/src/network/access/qnetworkaccessftpbackend.cpp#line350 for what the backend expects from the response. It's not complicated.
It is not configurable.
You can see the source code of what's happening here: http://qt.gitorious.org/qt/qt/blobs/4.7/src/network/access/qnetworkaccessftpbackend.cpp#line300
If you can build your own version of Qt, then it can easily be suppressed. But it might be easier for you to upgrade your FTP server to support the HELP command.

APOP Authentication withe libcurl

Has anyone had any success with libcurl and POP3 with APOP authentication?
I had success with the clear authentication but not with APOP since the library
sends the USER command almost immediately after making a connection.
How do I make libcurl send APOP command and stop it sending USER command?
libcurl currently doesn't support APOP. You need to dive in and make it so!

Are there any CURL alternatives for C++?

I hate CURL it is too bulky with too many dependencies when all I need to do is quickly open a URL. I don't even need to retrieve the contents of the web page, I just need to make the GET HTTP request to the server.
What's the most minimal way I can do this and don't say CURL !##$
There are lots of choices! Try libwww -- but be warned, most people strongly prefer libcurl. It's much easier to use.
There's a very light way and I've done this myself when implementing a high-scale back end service for a large media provider in the UK.
This method is extremely operating-system specific.
open a TCP socket to the HTTP server
send a "GET /path/to/url HTTP/1.1\r\nHost: www.host.com\r\n\r\n" (the Host header is required for HTTP/1.1 and most virtual servers, don't forget the two blank lines, and a newline requires a carriage return as well for HTTP headers)
wait for the response
close the socket
If you are going to close the socket at the end of the connection you may also want to send a Connection: close\r\n as part of your headers to inform the web server that you will terminate the connection after retrieving the web page.
You may run into trouble if you're fetching an encoded or generated web page in which case you'll have to add logic to interpret the fetched data.
On Windows (Windows XP, Windows 2000 Professional with SP3 and above) you could use WinHttpReadData API. There's also an example at the bottom of that page.
More info on Windows HTTP Services on MSDN
I have used Winsock when I need as few dependencies as possible and it has worked well. You need to write more code than using a separate library or the Microsoft WinHTTP library.
The functions you need are WSAStartup, socket, connect, send, recv, closesocket and WSACleanup.
See sample code for the send function.
system("wget -q -O file.htm http://url.com");

How to send POST request to some website using winapi?

I'd like to send HTTP POST request to website and retrieve the resultant page using winapi. How can I do that?
The MSDN docs have sample code using WinHTTP:
IWinHttpRequest::Send Method
Posting Data to the Server
Also consider using something like Libwww or libcurl.
You'll need to use Winsock (basically the Windows version of Berkeley sockets), create & send the HTTP request and receive & parse the response.