curl-and-php
Re: Newlines being lost during curl transmission
Date: Fri, 24 Oct 2003 08:30:46 +0200 (CEST)
On Fri, 24 Oct 2003, Matthew Hellinger wrote:
(CC'ing this reply to the curl and php list, seems suitable to me.)
> I am having an unexpected problem with a PHP script that I wrote. The script
> uses curl to post to a textarea. It works fine, except for when the message
> being posted contains a newline character. What happens is that the newline
> character appears to be lost when the form is submitted. The form does not
> normally strip newline characters (when accessing it using a web browser),
> so I've ruled this possibility out. I've tried using \r , \r\n , and \n to
> specify a newline in the textarea element, but all variants appear to get
> stripped.
Please show us a trace/dump/analyze of what is sent by curl (CURLOPT_VERBOSE).
You say they are stripped, but I don't believe you. libcurl doesn't ever strip
or convert any data you pass on to it, and I don't think PHP does either.
> I'm including sample code.
Right, but what did you assume the code to do? Did you really mean to make a
multipart formpost for example?
This example looks like it is sending the newlines fine.
> I've tested to verify that the $message is printing the newline and that the
> 'field2' element of the $submit array contains the newline character. Am I
> missing something in the curl initialization protocol?
I think it looks fine.
> What else could be the problem be, except for one of the curl function
> calls?
You could have a bug in how you receive/interpret the POST in the receiving
end. It could be a dozen other explanations as well, and the quickest way to
find out is to first check carefully what data that curl actually sends away.
Personally, I always recommend and practise this:
Use the curl command tool first to work out the functionality.
-- Daniel Stenberg -- curl: been grokking URLs since 1998 ------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/Received on 2003-10-24