cURL / Mailing Lists / curl-library / Single Mail

curl-library

More socks5

From: Andy Cedilnik <andy.cedilnik_at_kitware.com>
Date: 15 Jan 2003 10:08:25 -0500

Hi All,

So, after my first happyness when I discovered that SOCKS5 proxying
works, I tried to upload file using it. This is the code:

int main(void)
{
  CURL *curl;
  CURLcode res;

  struct HttpPost *formpost=NULL;
  struct HttpPost *lastptr=NULL;

  /* Fill in the file upload field */
  curl_formadd(&formpost, &lastptr,
                        CURLFORM_COPYNAME, "FileData",
                        CURLFORM_FILE, "file.txt",
                        CURLFORM_END);
  curl_formadd(&formpost, &lastptr,
                        CURLFORM_COPYNAME, "FileName",
                        CURLFORM_COPYCONTENTS, "uploadname.txt",
                        CURLFORM_END);

  curl_global_init(CURL_GLOBAL_DEFAULT);
  curl = curl_easy_init();
  if(curl)
  {
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    curl_easy_setopt(curl, CURLOPT_PROXY, "proxy");
    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
    curl_easy_setopt(curl, CURLOPT_URL,
"http://some.site.com/cgi-bin/HTTPUpload.cgi");
    res = curl_easy_perform(curl);
    printf("Res: %d\n", res);
    curl_easy_cleanup(curl);
  }
  return 0;
}

If I comment out line:

curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);

then things work fine. I get the page. If I have that line, then I get
the following output:

* About to connect() to proxy:1080
* Connected to .site.com ((nil)) port 1080
> POST http://some.site.com/cgi-bin/HTTPUpload.cgi HTTP/1.1
Host: some.site.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 146
Expect: 100-continue
Content-Type: multipart/form-data;
boundary=curlUI41vQHyr0VOaJukMynowCwUX64

And then it waits for long time.

I know that connection is established, since I see that script was run
on the server. Even more, I wrote environment from the script and I can
see things like:

CONTENT_TYPE -> multipart/form-data;
boundary=curlUI41vQHyr0VOaJukMynowCwUX64

The moment I try to do:
form = cgi.FieldStorage()

The script locks and waits. I assume the curl does not send the data.
After log time of waiting I get the following output on curl side:

* Connection #0 left intact
Res: 0
* Closing connection #0

So, I think the socks5 code has some problems. Except if I am doing
something wrong?

Any help apreciated.

Thank you.

                                Andy

-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving
your online business a competitive advantage. Test-drive a Thawte SSL
certificate - our easy online guide will show you how. Click here to get
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
Received on 2003-01-15