Simon Alexander | 25 Jul 23:27 2014

Can you force a connection to close via the command line?

Is there anyway to force the closure of a connection using the curl command line?

We have a situation where after performing a curl sftp upload of a file, we get the message "Connection #0 to host left intact" and then the command hangs.

I aware of the CURLOPT_FORBID_REUSE option if using libcurl, but we're using curl within a shell script.

From what I've read there doesn't appear to be a similar command line option. Am I missing something?
List admin:
Priyanka Shah | 16 Jul 21:52 2014

curl does not detect 'no space left on device' during scp

It looks like curl cannot detect 'no space left on device' when I try to copy file using scp. It returns success, but the copied file size is zero bytes.

$ curl --version
curl 7.36.0 (x86_64-unknown-linux-gnu) libcurl/7.36.0 OpenSSL/1.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

I found a similar thread/bug report here, where curl was not detecting ENOSPACE for small files.

I tried the same steps from there, and curl errors out now for that experiment. But I don't see any errors when I use scp.

$ ls -trl testfile
-rw-r--r-- 1 prishah2 prishah2 345898 Jun 17 10:31 testfile

$ curl -T testfile -u prishah2 scp://localhost/space/ -k
Enter host password for user 'prishah2':
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0  337k      0  71612 --:--:--  0:00:04 --:--:-- 95341
  0     0    0     0    0  337k      0  71595 --:--:--  0:00:04 --:--:-- 71595

$ echo $?

$ ls -trl /space/cores
-rw-r--r-- 1 prishah2 ifc 0 Jul 16 11:43 /space/testfile

Is this is known bug with curl? Is there some way I can detect this situation from my application code?
List admin:
gilles | 17 Jul 18:13 2014

Inconsistent request with dubious return code

 I was testing an upload to a FTP server under the same file name, 
such as:

  curl -T uploadfile -u user:passwd

 But I mistakenly wrote -O instead of -T.

 So my request is inconsistent because -O is for a download and 
I specified no file name.

 I got "Remote file name has no length!" which is ok.

 And curl returned a directory listing instead [should programs 
interpret an incorrectly formed request?].

 But the return code is 0! 

 I would definitely expect to have a meaningful return code 
in this case, because the intended action was not achieved.

 ~ Gilles

List admin:
Prashant Pharate | 17 Jul 12:13 2014

Handling MultiPart response in CURL


I have requirement. I will send 2 files in com.sun.jersey.multipart.MultiPart BodyPart  and will add multiPart object in response

My question is how I will get files from the response using CURL

My curl version is curl 7.19.7 (powerpc-ibm-aix5.3.0.0) libcurl/7.19.7 OpenSSL/0.9.8r

Protocols: tftp ftp telnet dict http file https ftps

Features: IPv6 Largefile NTLM SSL

Prashant Pharate
List admin:
a6786285 | 3 Jul 00:44 2014

7.37.0: man page typo

Please change

  Many of the options require an addition value next to it.


  Many of the options require an additional value next to them.


a happy curl user
List admin:
Amit Wankhede | 2 Jul 14:33 2014

Curl KeepAlive + Digest Authentication

Hi ,

I am trying to test an application which support both Digest Authentication and persistent connection (HTTP Header Connection :  keep-alive)

Here what i am trying is

curl --digest -u username:password http://sampleurl/fil1.txt http://sampleurl/fil2.txt

So, here the first url download works but, second one fails because it uses the 'nonce' for the first url. So, the server rejects the second url with 401 So, support Replay attack.

Now, Here I found a workaround  as below  where i need to supply second url again.

curl --digest -u username:password http://sampleurl/fil1.txt http://sampleurl/fil2.txt http://sampleurl/fil2.txt

After analyzing the HTTP request/response header I found that for the second url after it return 401 (Authentication failure) It returns a new 'nonce'
which gets reused for the third url and then it works.

I tried creating the bash file and calling curl command twice but, here it doesn't use the persistent connection it creates a new client socket for each  curl command.

So, my question is there any standard way to support this scenario in curl where server supports persistent connection as well as digest authentication.

Amit W

List admin:
gerd_roethig | 2 Jul 10:57 2014

Curl and transparent proxies (e.g. Squid)

Hello all and best greetings,
I already did quite some research on various sources in the net but was not able to find anything helpful for my particular problem.
The screnario is that I have some client PCs in a network behind a transparent proxy (squid/3.1.12).
Everything works fine using a browser set to "automatically detect network settings". Interestingly, if I set the browser to "no proxy" as I would have expected to be possible when using transparent proxies, the browser is not able to get anything from the web.
But how do I configure curl in this scenario?
If I omit proxy settings entirely, I get a "connection refused" error on every URL I want to access.
If I provide the proxy address and port with the -proxy option, I get the following:
E:\apps\flash>curl -x -v
* About to connect() to proxy port 80 (#0)
*   Trying
* Connected to ( port 80 (#0)
> GET HTTP/1.1
> User-Agent: curl/7.29.0
> Host:
> Accept: */*
> Proxy-Connection: Keep-Alive
< HTTP/1.1 404 Not Found
< Date: Wed, 02 Jul 2014 08:55:07 GMT
< Server: Apache/2.2.12 (Linux/SUSE)
< Vary: accept-language,accept-charset
< Accept-Ranges: bytes
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=iso-8859-1
< Content-Language: en
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" lang="en" xml:lang="en">
<title>Object not found!</title>
<link rev="made" href="mailto:%5bno%20address%20given%5d" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
<h1>Object not found!</h1>

    The requested URL was not found on this server.
    If you entered the URL manually please check your
    spelling and try again.
If you think this is a server error, please contact
the <a href="mailto:%5bno%20address%20given%5d">webmaster</a>.
<h2>Error 404</h2>
  <a href="/"></a><br />
  <span>Wed Jul  2 10:55:07 2014<br />
  Apache/2.2.12 (Linux/SUSE)</span>
* Connection #0 to host left intact
What settings do I have to provide to curl so that it can handle that transparent proxy properly?
Thank you very much for your help in advance and kind regards,
List admin:
Priyanka Shah | 2 Jul 06:15 2014

libcurl closing fd zero

I see some strange behaviour when using libcurl to send data over scp. Whenever authentication fails (curl error code 67), I see that curl frees up fd zero (calls close(0)). And this causes unexpected behaviour in my application. 

Here is the trace I got while debugging the issue:

#4  0xf3930a45 in ?? () from /usr/lib/

#5  0xf3930fcc in libssh2_agent_disconnect () from /usr/lib/

#6  0xf3ec63dc in ssh_statemach_act () from /usr/lib/

#7  0xf3ec8753 in ssh_easy_statemach () from /usr/lib/

#8  0xf3ec8c34 in ssh_connect () from /usr/lib/

#9  0xf3ea7932 in Curl_protocol_connect () from /usr/lib/

#10 0xf3ea7c12 in Curl_setup_conn () from /usr/lib/

#11 0xf3ea7ca6 in Curl_connect () from /usr/lib/

#12 0xf3eb3d11 in Curl_do_perform () from /usr/lib/

#13 0xf3eb4a43 in curl_easy_perform () from /usr/lib/

Any help will be appreciated.



List admin:
Madhavi Gundeti | 24 Jun 12:43 2014

Curl error code 35 after Mac OS upgrade from Mountain Lion to Mavericks



I am getting curl errors 35 and 28 continuously for my application after upgrading the Mac OS from Mountain Lion to Mavericks.

 If I freshly install my application on Mavericks then no SSL errors. Only during upgrades I am seeing these errors.


I found info regarding this at below URL.

 But how to build our own curl? It will be great help if you provide some examples.

I found one temporary solution which is working 70%(means not working all the time) adding SSLv3 version to the curl request.


My Application Sample Code:

CURLcode res;

FILE *f = 0;

const std::string& url = // Here the server URL;

f = fopen(m_OutputFilename.c_str(), "w");


return false;

char cError[CURL_ERROR_SIZE]="";

curl_easy_setopt (m_pCURL, CURLOPT_ERRORBUFFER, &cError );

curl_easy_setopt(m_pCURL, CURLOPT_TIMEOUT, 30); // 30 seconds time limit

curl_easy_setopt(m_pCURL, CURLOPT_URL, url.c_str());

curl_easy_setopt(m_pCURL, CURLOPT_USERAGENT, s_UserAgent.c_str());

curl_easy_setopt(m_pCURL, CURLOPT_HTTPPOST, form.GetForm());

curl_easy_setopt(m_pCURL, CURLOPT_NOSIGNAL, 1);



curl_easy_setopt(m_pCURL, CURLOPT_WRITEFUNCTION, CWebRequest::CURLWriteCallback);

curl_easy_setopt(m_pCURL, CURLOPT_FILE, f);


curl_easy_setopt(m_pCURL, CURLOPT_SSLVERSION, 3); //Added for OS upgrade bug fix.

res = curl_easy_perform(m_pCURL);

MessageLog.Write("cURL return code", res);

MessageLog.Write("Error Message", cError);

// Below loop added because after 7th attempt curl call succeeded(This is inconsistent).

if(res != 0)


int count1 = 0;

while (count1 < 10)


res = curl_easy_perform(m_pCURL);

MessageLog.Write("cURL return code", res);

MessageLog.Write("Error Message", cError);

if(res == 0)





Error Log:

Adding handle: conn: 0x180a000

, 0000000031 bytes (0x0000001f)

0000: Adding handle: conn: 0x180a000.

Adding handle: send: 0

, 0000000023 bytes (0x00000017)

0000: Adding handle: send: 0.

Adding handle: recv: 0

, 0000000023 bytes (0x00000017)

0000: Adding handle: recv: 0.

Curl_addHandleToPipeline: length: 1

, 0000000036 bytes (0x00000024)

0000: Curl_addHandleToPipeline: length: 1.

- Conn 0 (0x180a000) send_pipe: 1, recv_pipe: 0

, 0000000048 bytes (0x00000030)

0000: - Conn 0 (0x180a000) send_pipe: 1, recv_pipe: 0.

About to connect() to SERVER port 443 (#0)

, 0000000060 bytes (0x0000003c)

0000: About to connect() to SERVER port 443 (#0).

  Trying X.X.X.X...

, 0000000025 bytes (0x00000019)

0000:   Trying X.X.X.X....

Connected to SERVER (X.X.X.X) port 443 (#0)

, 0000000066 bytes (0x00000042)

0000: Connected to SERVER (X.X.X.X) port 443 (#0).

Unknown SSL protocol error in connection to SERVER:-36

, 0000000072 bytes (0x00000048)

0000: Unknown SSL protocol error in connection to SERVER:-36.

Please suggest me how to solve this SSL issue permanently.

Thanks and Regards,
Madhavi G.
List admin:
Pawan Kumar | 19 Jun 13:04 2014

To know more about cURL

Dear Sir,

I am Pawan Kumar. I wanted to make a program to download a file from server
of a particular link and i made using the cURL but i want explore more how exactly download load a file
using socket level API.  I am very interested to know socket level programs how to download a file
from server. It will very helpful if you let me know which part of coding responsible for downloading the file.
I know it is open source but it is very difficult for me to understand whole code.
It will be very helpful if you let me know what exact file and line responsible
for downloading a file.

Warmly Yours

Pawan Kumar
e-mail: thepawan_dear <at>
List admin:
PenguinWhispererThe . | 11 Jun 11:11 2014

Using curl to setup TCP connection through squid proxy

Hi all,

I'm setting up a nagios machine and it's behind a proxy.
For this machine the connect method is allowed to all ports.

The idea is to use curl with the proxytunnel option and open a TCP connection like that to other protocols: SMTP, IMAP, ... I would be happy if I already could do a TCP check (so the proxy being able to connect).
Is this possible using curl?

curl -x x.x.x.x:3128 --proxytunnel -v

However I see the proxy sending HTTP requests (or that is what it looks like).

When I use SMTP as the protocol (so in the proxytunnel part):
curl: (1) Protocol smtp not supported or disabled in libcurl

Is there a generic way where curl only sets up the connection through the proxy and the protocol is handled by me?

Are there alternatives to accomplish this? Like telnetting and writing the connect statements myself (not sure what the proxy expects to see to set up a tunnel (CONNECT hostname:port probably but maybe more than that).

Thanks a lot in advance!
List admin: