POSTing data does not seem to work?

62 views
Skip to first unread message

Jeff Warrren

unread,
Jul 22, 2011, 9:31:00 AM7/22/11
to curlpp
I have been working off the example given at http://curlpp.org/index.php/examples/62-example-12,
along with a php script which will just print out whatever is posted
to it.

(i.e. <? var_dump($_POST) ?> )

No matter what I have tried, including variations on the example
above, the PHP script never seems to receive anything. Am I doing
something incorrectly, or is there possibly a bug in curlpp?

Zach Mance

unread,
Jul 22, 2011, 2:31:56 PM7/22/11
to curlpp
I've been able to use POST things, I'll try to help you. Could you
post more of the code you are working with?

Thanks,
Zach

On Jul 22, 8:31 am, Jeff Warrren <jeff.war...@gmail.com> wrote:
> I have been working off the example given athttp://curlpp.org/index.php/examples/62-example-12,

Jeff Warrren

unread,
Jul 24, 2011, 10:30:15 PM7/24/11
to curlpp
Sure.

My C++ code is as follows:

std::stringstream out;
std::stringstream ss;
ss << "127.0.0.1/online.php";

try
{
curlpp::Cleanup clean;
curlpp::Easy request;
curlpp::options::WriteStream ws(&out);
request.setOpt(ws);
request.setOpt<curlpp::options::Url>(ss.str());
request.setOpt(new curlpp::options::Verbose(true));

std::list<std::string> header;
header.push_back("Content-Type: application/octet-stream");
request.setOpt(new curlpp::options::HttpHeader(header));

std::string test = "abcd=abcd";

request.setOpt(new curlpp::options::PostFields(test));
request.setOpt(new curlpp::options::PostFieldSize(test.length()));

request.perform();
}
catch(curlpp::RuntimeError& e)
{
ss.str("");
ss << "Error making request of type " << op << ": " << e.what();
PrintError(ss.str());
return "";
}

std::cout << out.str() << std::endl;

return out.str();


And the web script end is just <? var_dump($_POST); ?> as mentioned
before. Command line curl has it print the sent data as expected.


Thanks,
Jeff

Jeff Warrren

unread,
Jul 26, 2011, 7:15:31 AM7/26/11
to curlpp
Fixed - the content type descriptor was wrong. Should have been:
application/x-www-form-urlencoded

Zach Mance

unread,
Jul 26, 2011, 10:34:25 AM7/26/11
to cur...@googlegroups.com
Ah yes, that would do it! I've had that issue before as well. I'm glad you figured it out, when I looked at your code it looked all there to me. I just didn't have the time to dig deeper into the issue. Thank you for posting back that you solved the issue.

-Zachary


On Tuesday, July 26, 2011, Jeff Warrren <jeff....@gmail.com> wrote:
> Fixed - the content type descriptor was wrong. Should have been:
> application/x-www-form-urlencoded
>
> --
> You received this message because you are subscribed to the Google Groups "curlpp" group.
> To post to this group, send email to cur...@googlegroups.com.
> To unsubscribe from this group, send email to curlpp+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/curlpp?hl=en.
>
>

--
_ZAM_
Reply all
Reply to author
Forward
0 new messages