This is a discussion on Re: limiting transferred data using curl within the PHP Language forums, part of the PHP Programming Forums category; Hi, You can terminate the download in your WRITEFUNCTION callback by returning 0. Here's an example: <? error_reporting(E_ALL | ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
You can terminate the download in your WRITEFUNCTION callback by returning 0. Here's an example: <? error_reporting(E_ALL | E_STRICT); // This class encapsulates the callback functions class curlHandler { var $data; var $readCount = 0; var $maxRead = 20000; function writeProc($ch, $str) { $len = strlen($str); $n = min($this->maxRead - $this->readCount, $len); $this->data .= substr($str, 0, $n); $this->readCount += $n; echo "Read {$this->readCount} bytes (max {$this->maxRead}).<br> \n"; if ($this->readCount >= $this->maxRead) { return 0; } return $len; } } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.php.net'); $cp = new curlHandler; curl_setopt($ch, CURLOPT_WRITEFUNCTION, array(&$cp, 'writeProc')); curl_exec($ch); echo "<br>\nGot " . strlen($cp->data) . " bytes.<br><br>\n\n"; echo "CURL statistics:<br><br>\n\n"; $info = curl_getinfo($ch); var_dump($info); curl_close($ch); ?> Regards, John Peters On Feb 26, 11:54 am, "shika...@gmail.com" <shika...@gmail.com> wrote: > Hi! > > I have a server I'd like to download hundreds of pages from, and only > get the first few kilobytes of every page to save resources on both > my > and the remote end. Since the server doesn't support HTTP range to > use it in curl like curl_setopt($ch, CURLOPT_RANGE, "0-5000"); I > started looking around and found that using the custom write function > I might be able to do the same. > > As I understand it, closing the handle and thus terminating the > transfer from within the callback function is not possible, so I'm a > bit stuck.. > > How could I get this done? Could someone paste me a fewliner example? > > Thanks in advance > Andrew |
|
|||
|
Captain Paralytic,
If you *MUST* make an off topic post, please preface the subject with "[OT]", so those who are not interested in OT posts can skip them. On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: > On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: > > > Hi, > > Hey John, > which part of "Please do not top post" is it that you are having > trouble understanding? |
|
|||
|
esaniah@gmail.com wrote:
> On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: >> On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: >> >>> Hi, >> Hey John, >> which part of "Please do not top post" is it that you are having >> trouble understanding? > > > Captain Paralytic, > > If you *MUST* make an off topic post, please preface the subject with > "[OT]", so those who are not interested in OT posts can skip them. > (Top posting fixed) It is not off topic in this newsgroup to ask people to not top post. Intertwined or bottom posting is the norm for this newsgroup. Please don't top post! -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
esaniah@gmail.com wrote:
> On Feb 28, 9:19 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> esan...@gmail.com wrote: >>> On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: >>>> On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: >>>>> Hi, >>>> Hey John, >>>> which part of "Please do not top post" is it that you are having >>>> trouble understanding? >> > Captain Paralytic, >> > >> > If you *MUST* make an off topic post, please preface the subject with >> > "[OT]", so those who are not interested in OT posts can skip them. >> > >> >> (Top posting fixed) >> >> It is not off topic in this newsgroup to ask people to not top post. >> Intertwined or bottom posting is the norm for this newsgroup. >> >> Please don't top post! >> > Jerry, > > You're completely misrepresenting the newsgroup's charter. > > "comp.lang.php is intended to be a global forum for the discussion of > issues involving PHP ... Since database connectivity is a large part > of PHP, it will be considered topical in comp.lang.php." > > PHP and databases are on-topic. Posting styles are not. How hard is it > to use [OT] like everyone else? > (Top posting fixed again) Because suggesting people follow the norms for this newsgroup is within the bounds of the newsgroup. Period. You can keep top posting if you want - but don't expect to get much help from this newsgroups. A. Because they are either idiots or assholes. Q. Why do people continue to top post? A. We politely let them know the correct way to post. Q. What do you do about it? A. Because they don't know any better. Q. Why do people top post? A. Because it interrupts the normal flow of the messages. Q. Why is it so annoying? A. Top posting. Q. What's the most annoying thing on usenet? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Jerry,
You're completely misrepresenting the newsgroup's charter. "comp.lang.php is intended to be a global forum for the discussion of issues involving PHP ... Since database connectivity is a large part of PHP, it will be considered topical in comp.lang.php." PHP and databases are on-topic. Posting styles are not. How hard is it to use [OT] like everyone else? On Feb 28, 9:19 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: > esan...@gmail.com wrote: > > On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: > >> On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: > > >>> Hi, > >> Hey John, > >> which part of "Please do not top post" is it that you are having > >> trouble understanding? > > > Captain Paralytic, > > > > If you *MUST* make an off topic post, please preface the subject with > > "[OT]", so those who are not interested in OT posts can skip them. > > > > (Top posting fixed) > > It is not off topic in this newsgroup to ask people to not top post. > Intertwined or bottom posting is the norm for this newsgroup. > > Please don't top post! > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ================== |
|
|||
|
..oO(esaniah@gmail.com)
>You're completely misrepresenting the newsgroup's charter. > >"comp.lang.php is intended to be a global forum for the discussion of >issues involving PHP ... Since database connectivity is a large part >of PHP, it will be considered topical in comp.lang.php." > >PHP and databases are on-topic. Posting styles are not. How hard is it >to use [OT] like everyone else? It's even easier to ignore people like you who don't want to respect even the most basic rules in a community to make it as easy as possible for the members of that community to offer their help for free. You shouldn't bite the hand that feeds you. Micha |
|
|||
|
Jerry,
Whining about posting styles is not and has never been on topic for this newsgroup. If you are interested in improving the single-to-noise ratio in this group, you will follow the same standards that everyone else does and use "[OT]" when discussing topics unrelated to PHP and databases. If you wish to continue posting off-topic content without warning folks, that's a quick way to get yourself kill-filed by a large number of readers. On Feb 28, 10:42 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: > esan...@gmail.com wrote: > > On Feb 28, 9:19 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: > >> esan...@gmail.com wrote: > >>> On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: > >>>> On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: > >>>>> Hi, > >>>> Hey John, > >>>> which part of "Please do not top post" is it that you are having > >>>> trouble understanding? > >> > Captain Paralytic, > > >> > If you *MUST* make an off topic post, please preface the subject with > >> > "[OT]", so those who are not interested in OT posts can skip them. > > >> (Top posting fixed) > > >> It is not off topic in this newsgroup to ask people to not top post. > >> Intertwined or bottom posting is the norm for this newsgroup. > > >> Please don't top post! > > > Jerry, > > > > You're completely misrepresenting the newsgroup's charter. > > > > "comp.lang.php is intended to be a global forum for the discussion of > > issues involving PHP ... Since database connectivity is a large part > > of PHP, it will be considered topical in comp.lang.php." > > > > PHP and databases are on-topic. Posting styles are not. How hard is it > > to use [OT] like everyone else? > > > > (Top posting fixed again) > > Because suggesting people follow the norms for this newsgroup is within > the bounds of the newsgroup. Period. > > You can keep top posting if you want - but don't expect to get much help > from this newsgroups. > > A. Because they are either idiots or assholes. > Q. Why do people continue to top post? > A. We politely let them know the correct way to post. > Q. What do you do about it? > A. Because they don't know any better. > Q. Why do people top post? > A. Because it interrupts the normal flow of the messages. > Q. Why is it so annoying? > A. Top posting. > Q. What's the most annoying thing on usenet? > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ================== |
|
|||
|
esaniah@gmail.com wrote:
> On Feb 28, 10:42 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> esan...@gmail.com wrote: >>> On Feb 28, 9:19 am, Jerry Stuckle <jstuck...@attglobal.net> wrote: >>>> esan...@gmail.com wrote: >>>>> On Feb 28, 8:09 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: >>>>>> On 28 Feb, 14:04, petersprc <peters...@gmail.com> wrote: >>>>>>> Hi, >>>>>> Hey John, >>>>>> which part of "Please do not top post" is it that you are having >>>>>> trouble understanding? >>>> > Captain Paralytic, >>>> > If you *MUST* make an off topic post, please preface the subject with >>>> > "[OT]", so those who are not interested in OT posts can skip them. >>>> (Top posting fixed) >>>> It is not off topic in this newsgroup to ask people to not top post. >>>> Intertwined or bottom posting is the norm for this newsgroup. >>>> Please don't top post! >> > Jerry, >> > >> > You're completely misrepresenting the newsgroup's charter. >> > >> > "comp.lang.php is intended to be a global forum for the discussion of >> > issues involving PHP ... Since database connectivity is a large part >> > of PHP, it will be considered topical in comp.lang.php." >> > >> > PHP and databases are on-topic. Posting styles are not. How hard is it >> > to use [OT] like everyone else? >> > >> >> (Top posting fixed again) >> >> Because suggesting people follow the norms for this newsgroup is within >> the bounds of the newsgroup. Period. >> >> You can keep top posting if you want - but don't expect to get much help >> from this newsgroups. >> >> A. Because they are either idiots or assholes. >> Q. Why do people continue to top post? >> A. We politely let them know the correct way to post. >> Q. What do you do about it? >> A. Because they don't know any better. >> Q. Why do people top post? >> A. Because it interrupts the normal flow of the messages. >> Q. Why is it so annoying? >> A. Top posting. >> Q. What's the most annoying thing on usenet? >> > Jerry, > > Whining about posting styles is not and has never been on topic for > this newsgroup. If you are interested in improving the single-to-noise > ratio in this group, you will follow the same standards that everyone > else does and use "[OT]" when discussing topics unrelated to PHP and > databases. > > If you wish to continue posting off-topic content without warning > folks, that's a quick way to get yourself kill-filed by a large number > of readers. > (Top posting fixed) No, you're just showing what an ass you are by continuing to top post. Go ahead and plonk me if you want. I'm sure a lot of other regulars in this group have already *plonked you*. But that's what happens when you get a troll coming in through google groups. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
On Fri, 29 Feb 2008 10:22:55 -0800, esaniah wrote:
> Jerry, > > Whining about posting styles is not and has never been on topic for this > newsgroup. If you are interested in improving the single-to-noise ratio > in this group, you will follow the same standards that everyone else > does and use "[OT]" when discussing topics unrelated to PHP and > databases. You couldn't be more wrong. By top posting you have turned the thread into a thread about top posting. Please don't top post. -- I told you this was going to happen. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|