0

I have an asynchronous curl crawler which works well without CURLOPT_WRITEFUNCTION enabled.

I am trying to limit the amount of data downloaded with CURLOPT_WRITEFUCNTION by stopping any downloads that go over 1mb in size.

The problem I am having is that curl_multi_getcontent($done['handle']) doesn't return any data when I use CURLOPT_WRITEFUCNTION.

I know I can play with the data inside of CURLOPT_WRITEFUCNTION's function, but it would make things much easier if curl_multi_getcontent($done['handle']) continued to do it's job in conjunction with CURLOPT_WRITEFUCNTION.

Is it possible to use curl_multi_getcontent and CURLOPT_WRITEFUNCTION together?

darkAsPitch
  • 1,855
  • 4
  • 23
  • 35
  • Is this what you are looking for? http://stackoverflow.com/questions/15906261/parallel-curl-request-with-writefunction-callback/15958698#15958698 – Aleksander Wons Apr 22 '15 at 06:27
  • @awons no, unfortunately. His posts have been the only ones I have found concerning CURLOPT_WRITEFUNCTION and curl multi with php, and he has no idea what he's talking about... it doesn't matter where you place CURLOPT_WRITEFUNCTION in the setopt array, I just tried placing it at the end and there was no difference in outcome. – darkAsPitch Apr 22 '15 at 17:29

1 Answers1

0

The answer to my own question is this:

CURLOPT_RETURNTRANSFER is basically a built in WRITEFUNCTION.

When you specify another WRITEFUNCTION, you override CURLOPT_RETURNTRANSFER and thus have to RETURNTRANSFER yourself if that's what you're trying to do.

I wish the php curl package would have thrown an error along the lines of "warning: CURLOPT_WRITEFUNCTION overrides CURLOPT_RETURNTRANSFER" but I'm sure they have their reasons for not doing so.

darkAsPitch
  • 1,855
  • 4
  • 23
  • 35