By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

blank response from curl when posting form data

P: n/a

Here is my code, and the problem:

$st="...(string to post is formed from different variables read from
file)...";
$lngth=strlen($st);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url2);
$fp = fopen("example_homepage2.txt", "w");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,20);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDSIZE, $lngth);
curl_setopt($ch, CURLOPT_POSTFIELDS, $st);
$page2=curl_exec($ch);
curl_close($ch);
fclose($fp);

I tried both with and without POSTFIELDSIZE option, with same result.
This code works fine for strings smaller than 800 characters (actually
795 or so), but my regular string is just under 13000 characters.
I have uploaded the script to 5 webservers (including my development
machine with Win XP , PHP 5 and Apache 2.2.) and it only works on one.
The rest return a blank page to stare at on the curl post.
Is this some configuration issue, or a curl issue?
Any advice?

Nov 22 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
ap****@gmail.com wrote:
Here is my code, and the problem:

$st="...(string to post is formed from different variables read from
file)...";
<snip>
curl_setopt($ch, CURLOPT_POSTFIELDS, $st);
curl_setopt($ch, CURLOPT_POSTFIELDS, rawurlencode($st));
$page2=curl_exec($ch);
curl_close($ch);
fclose($fp);

Any advice?
urlencode() or rawurlencode() your POSTFIELDS.

http://php.net/urlencode
http://php.net/rawurlencode
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Nov 22 '06 #2

P: n/a
I forgot to mention: they are properly encoded with urlencode. I
checked against Firefox headers. As soon as I make those strings small,
under 800 characters, everything works. This is checked against several
webhosts too: Godaddy, Bluehost, Network Solutions, and my own server,
all return the same error:

cURL ERROR #56: Received problem 2 in the chunky parser at 186 in
/home/public_html/poster.php
I have this at line 186:
if(curl_errno($ch) 0) echo "<p style='color: red'><b>cURL ERROR
#".curl_errno($ch).": ".curl_error($ch)." at ".__LINE__." in
".__FILE__."</b></p>";

If I take that line out, I get a blank response from the Post.
It only works without a hitch on Marblehost. So I'm thinking it may be
a config issue, but I need a way to make it work on my computer. This
is rather intriguing. I tried passing the post data in strings, arrays
and directly with the same result. I have also tried passing it a file,
which, I read, handles buffering better (doing that I'm returned the
blank form again, which I initially get on the previous step with a
simple curl call to that url without a post), but I am not sure I did
file passing correctly. Any example on how to do this correctly, as
well as any other advice would be really appreciated.

Nov 23 '06 #3

P: n/a
I forgot to mention: they are properly encoded with urlencode. I
checked against Firefox headers. The POSTFILEDS string is formed like
this
$st="field1=$var1&field2=$var2&field3=$var3...";
some 8 fields in all. The appropriate variables are already urlencoded
at this point. The thing, is I have to post the 10k text area content,
and here's where the hiccup occurs. As soon
as I make that string small, everything works. This is checked against
several
webhosts too: Godaddy, Bluehost, Network Solutions, and my own server,
all return the same error:

cURL ERROR #56: Received problem 2 in the chunky parser at 186 in
/home/public_html/poster.php
I have this at line 186:
if(curl_errno($ch) 0) echo "<p style='color: red'><b>cURL ERROR
#".curl_errno($ch).": ".curl_error($ch)." at ".__LINE__." in
".__FILE__."</b></p>";
If I take that line out, I get a blank response from the Post.
It only works without a hitch on Marblehost. So I'm thinking it may be
a config issue, but I need a way to make it work on my computer. This
is rather intriguing. I tried passing the post data in strings, arrays
and directly with the same result. I have also tried passing it a file,

which, I read, handles buffering better (doing that I'm returned the
blank form again, which I initially get on the previous step with a
simple curl call to that url without a post), but I am not sure I did
file passing correctly. Any example on how to do this correctly, as
well as any other advice would be really appreciated.

Nov 23 '06 #4

P: n/a
ap****@gmail.com wrote:
cURL ERROR #56: Received problem 2 in the chunky parser at 186 in
The first google hit for "problem 2 in the chunky parser" (with the
quotes)
http://www.google.com/search?q=%22pr...unky+parser%22

is
http://curl.haxx.se/mail/lib-2006-04/0046.html

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Nov 23 '06 #5

P: n/a
I'd love to see a fix for this. It seems like it might not be a problem
with curl but more of a problem with the http server's returned data.
Regardless I still can't seem to find a fix whatever the real problem
may be.

On Nov 23, 3:17 am, Pedro Graca <hex...@dodgeit.comwrote:
api...@gmail.com wrote:
cURL ERROR #56: Received problem 2 in the chunky parser at 186 inThe first google hit for "problem 2 in the chunky parser" (with the
quotes)
http://www.google.com/search?q=%22pr...unky+parser%22

is
http://curl.haxx.se/mail/lib-2006-04/0046.html

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Nov 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.