Re: [PHP] Curl doesn't handle memory stream

2008-02-14 Thread Richard Lynch


On Wed, February 13, 2008 8:19 pm, Nathan Nobbe wrote:
 On Feb 13, 2008 6:52 PM, Richard Lynch [EMAIL PROTECTED] wrote:

 On Wed, February 13, 2008 4:11 pm, Nathan Nobbe wrote:

 You may or may not want to file a bug report with curl itself,
 depending on whether PHP is doing the stream file handling or curl
 is.

 At a wild guess, I would expect it would be buried in curl code, not
 PHP code...

 Perhaps you can dig around here and find out for sure:
 http://lxr.php.net
 http://cvs.php.net

 thanks richard, even tho im not proficient w/ c ill take a look at it
 this
 weekend and see if i can make any headway.  i remember trying to look
 when this thread first started and i was like, u... yeah...
 but its worth another shot.  and the lxr link is pretty sweet too.  i
 like
 how
 they have links for all the line numbers of the source files :)

Having seen your sample code, it probably IS within the PHP code,
since you are passing a file handle to curl -- and it should behave as
a proper file handle, in an ideal world, as far as curl is
concerned...

But then curl may be doing something funky with it and making invalid
assumptions too...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Nathan Nobbe
On Nov 29, 2007 10:59 AM, Peter Smit [EMAIL PROTECTED] wrote:

 If nobody has a solution I think I'll report it as a bug tomorrow.


did you ever report a bug on this ?

i was messing around with it today, and i discovered that some urls,
partially work.  for example the google translate 'api', and php.net

note, i set the user agent for the google site to work.  and i say,
partially, because even when data does come back, its not the complete
page, which you can easily realize by navigating to the page and comparing
the source w/ the output from the test script.
i dont know of any ini setting that would influence the amount of space
available to the memory buffer, aside from memory_limit, which i have set
to 128M.

?php
#$c = curl_init(
http://google.com/translate_t?langpair=en%7Cfrtext=newspaper;);
$c = curl_init(http://php.net;);
$st = fopen('php://memory', 'r');

curl_setopt($c, CURLOPT_FILE, $st);
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.8.1.11) Gecko/20080115 Firefox/2.0.0.11');

if(!curl_exec($c)) die (error: .curl_error($c));
curl_close($c);

rewind($st);

echo stream_get_contents($st);
fclose($st);
?

-nathan


Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Manuel Lemos
Hello,

on 02/13/2008 05:17 PM Nathan Nobbe said the following:
 If nobody has a solution I think I'll report it as a bug tomorrow.
 
 
 did you ever report a bug on this ?
 
 i was messing around with it today, and i discovered that some urls,
 partially work.  for example the google translate 'api', and php.net
 
 note, i set the user agent for the google site to work.  and i say,
 partially, because even when data does come back, its not the complete
 page, which you can easily realize by navigating to the page and comparing
 the source w/ the output from the test script.
 i dont know of any ini setting that would influence the amount of space
 available to the memory buffer, aside from memory_limit, which i have set
 to 128M.
 
 ?php
 #$c = curl_init(
 http://google.com/translate_t?langpair=en%7Cfrtext=newspaper;);
 $c = curl_init(http://php.net;);
 $st = fopen('php://memory', 'r');
 
 curl_setopt($c, CURLOPT_FILE, $st);
 curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US;
 rv:1.8.1.11) Gecko/20080115 Firefox/2.0.0.11');
 
 if(!curl_exec($c)) die (error: .curl_error($c));
 curl_close($c);
 
 rewind($st);
 
 echo stream_get_contents($st);
 fclose($st);
 ?

It does not seem like it is a real bug but maybe file access is
implemented inside Curl and it has no knowledge about PHP stream support.

Alternatively, you may want to try this HTTP client class, which can use
any access files you need to use in your HTTP requests.

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Jim Lucas

Nathan Nobbe wrote:

On Nov 29, 2007 10:59 AM, Peter Smit [EMAIL PROTECTED] wrote:


If nobody has a solution I think I'll report it as a bug tomorrow.



did you ever report a bug on this ?

i was messing around with it today, and i discovered that some urls,
partially work.  for example the google translate 'api', and php.net

note, i set the user agent for the google site to work.  and i say,
partially, because even when data does come back, its not the complete
page, which you can easily realize by navigating to the page and comparing
the source w/ the output from the test script.
i dont know of any ini setting that would influence the amount of space
available to the memory buffer, aside from memory_limit, which i have set
to 128M.

?php
#$c = curl_init(
http://google.com/translate_t?langpair=en%7Cfrtext=newspaper;);
$c = curl_init(http://php.net;);
$st = fopen('php://memory', 'r');

curl_setopt($c, CURLOPT_FILE, $st);
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.8.1.11) Gecko/20080115 Firefox/2.0.0.11');

if(!curl_exec($c)) die (error: .curl_error($c));
curl_close($c);

rewind($st);

echo stream_get_contents($st);
fclose($st);
?

-nathan



I see on the http://us.php.net/wrappers.php page that only php 5.1.0 and newer 
have this feature.  What version of PHP are you using?


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Jim Lucas

Nathan Nobbe wrote:

On Nov 29, 2007 10:59 AM, Peter Smit [EMAIL PROTECTED] wrote:


If nobody has a solution I think I'll report it as a bug tomorrow.



did you ever report a bug on this ?



http://bugs.php.net/bug.php?id=43468

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Nathan Nobbe
On Feb 13, 2008 5:07 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 I see on the http://us.php.net/wrappers.php page that only php 5.1.0 and
 newer
 have this feature.  What version of PHP are you using?


thanks for your time jim;
im using 5.2.5.

manuel, thanks for your time as well.  of course i can just use a file,
but im somewhat interested in this feature.  and im not sure if curl
implements
the file handling on its own, otherwise why would i have partial success
with
certain urls?  i think something goofy is going on here; id like to find out
if
at all possible.  i know that some extensions may not support the feature,
but i could find no documentation that would say either way for the curl
extension..

-nathan


Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Nathan Nobbe
On Feb 13, 2008 5:10 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
  On Nov 29, 2007 10:59 AM, Peter Smit [EMAIL PROTECTED] wrote:
 
  If nobody has a solution I think I'll report it as a bug tomorrow.
 
 
  did you ever report a bug on this ?
 

 http://bugs.php.net/bug.php?id=43468


thanks jim ;)

-nathan


Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Richard Lynch


On Wed, February 13, 2008 4:11 pm, Nathan Nobbe wrote:
 On Feb 13, 2008 5:07 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 I see on the http://us.php.net/wrappers.php page that only php 5.1.0
 and
 newer
 have this feature.  What version of PHP are you using?


 thanks for your time jim;
 im using 5.2.5.

 manuel, thanks for your time as well.  of course i can just use a
 file,
 but im somewhat interested in this feature.  and im not sure if curl
 implements
 the file handling on its own, otherwise why would i have partial
 success
 with
 certain urls?  i think something goofy is going on here; id like to
 find out
 if
 at all possible.  i know that some extensions may not support the
 feature,
 but i could find no documentation that would say either way for the
 curl
 extension..

You may or may not want to file a bug report with curl itself,
depending on whether PHP is doing the stream file handling or curl is.

At a wild guess, I would expect it would be buried in curl code, not
PHP code...

Perhaps you can dig around here and find out for sure:
http://lxr.php.net
http://cvs.php.net

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Nathan Nobbe
On Feb 13, 2008 6:52 PM, Richard Lynch [EMAIL PROTECTED] wrote:

 On Wed, February 13, 2008 4:11 pm, Nathan Nobbe wrote:

 You may or may not want to file a bug report with curl itself,
 depending on whether PHP is doing the stream file handling or curl is.

 At a wild guess, I would expect it would be buried in curl code, not
 PHP code...

 Perhaps you can dig around here and find out for sure:
 http://lxr.php.net
 http://cvs.php.net


thanks richard, even tho im not proficient w/ c ill take a look at it this
weekend and see if i can make any headway.  i remember trying to look
when this thread first started and i was like, u... yeah...
but its worth another shot.  and the lxr link is pretty sweet too.  i like
how
they have links for all the line numbers of the source files :)

-nathan


Re: [PHP] Curl doesn't handle memory stream

2008-02-13 Thread Manuel Lemos
Hello

on 02/13/2008 08:11 PM Nathan Nobbe said the following:
 On Feb 13, 2008 5:07 PM, Jim Lucas [EMAIL PROTECTED] wrote:
 
 I see on the http://us.php.net/wrappers.php page that only php 5.1.0 and
 newer
 have this feature.  What version of PHP are you using?
 
 
 thanks for your time jim;
 im using 5.2.5.
 
 manuel, thanks for your time as well.  of course i can just use a file,
 but im somewhat interested in this feature.  and im not sure if curl
 implements
 the file handling on its own, otherwise why would i have partial success
 with
 certain urls?  i think something goofy is going on here; id like to find out
 if
 at all possible.  i know that some extensions may not support the feature,
 but i could find no documentation that would say either way for the curl
 extension..

THat is a bit intriguing why it works in some cases and others it doesn't.

I do not use the Curl library functions except for things that you
cannot do with the current fsockopen based socket connections. In the
latest PHP versions there is not much that you cannot do with socket
connections that you can do with Curl.

In any case, I have encapsulated HTTP client fucntionality in the class
that I mentioned, so it uses fsockopen or curl functions depending on
what you need and what is available in the underlying PHP version. This
way I achive a PHP version independent solution.


-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2007-11-29 Thread Peter Smit
On Nov 27, 2007 11:43 PM, Peter Smit [EMAIL PROTECTED] wrote:
 Hello,

 I've got quite a strange problem with the curl library.

 The following code does output Content||\Content instead of
 Content|example.orgoutput|\Content

 $c = curl_init(http://example.com;);
 $st = fopen(php://memory, r+);

 curl_setopt($c, CURLOPT_FILE, $st);

 if(!curl_exec($c)) die (error: .curl_error($c));

 rewind($st);
 echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
 fclose($st);


 If I use a file stream instead it works as expected:

 $c = curl_init(http://example.com;);

 $file = /tmp/phptest.rand().;
 touch($file);
 $st = fopen($file, r+);

 curl_setopt($c, CURLOPT_FILE, $st);

 if(!curl_exec($c)) die (error: .curl_error($c));

 rewind($st);
 echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
 fclose($st);
 unlink($file);


 What's the problem? Does PHP not support memory streams in Curl?

 Peter



Hello,

I don't know or it's allowed to kick thread, but I give it a try.
Does somebody have any idea why the Curl extension doesn't handle
memory streams?

Regards,

Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Curl doesn't handle memory stream

2007-11-29 Thread Nathan Nobbe
On Nov 29, 2007 7:56 AM, Peter Smit [EMAIL PROTECTED] wrote:

 On Nov 27, 2007 11:43 PM, Peter Smit [EMAIL PROTECTED] wrote:
  Hello,
 
  I've got quite a strange problem with the curl library.
 
  The following code does output Content||\Content instead of
  Content|example.orgoutput|\Content
 
  $c = curl_init(http://example.com;);
  $st = fopen(php://memory, r+);
 
  curl_setopt($c, CURLOPT_FILE, $st);
 
  if(!curl_exec($c)) die (error: .curl_error($c));
 
  rewind($st);
  echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
  fclose($st);
 
 
  If I use a file stream instead it works as expected:
 
  $c = curl_init(http://example.com;);
 
  $file = /tmp/phptest.rand().;
  touch($file);
  $st = fopen($file, r+);
 
  curl_setopt($c, CURLOPT_FILE, $st);
 
  if(!curl_exec($c)) die (error: .curl_error($c));
 
  rewind($st);
  echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
  fclose($st);
  unlink($file);


im curious to know where you discovered
php://memory
was a valid stream; i looked through the online manual and found no
reference to it.
nor did i find anything from google.  i did encounter it in the php source,
but with no
useful documentation.
a reference of all the streams that are valid with the php:// scheme would
be helpful.

getting to your problem, i think this could perhaps be a bug.
you might file a bug report and post your code along with it; unless
somebody has a
better idea ;)

-nathan


Re: [PHP] Curl doesn't handle memory stream

2007-11-29 Thread Peter Smit
On Nov 29, 2007 5:18 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Nov 29, 2007 7:56 AM, Peter Smit [EMAIL PROTECTED] wrote:

 
 
 
  On Nov 27, 2007 11:43 PM, Peter Smit [EMAIL PROTECTED] wrote:
   Hello,
  
   I've got quite a strange problem with the curl library.
  
   The following code does output Content||\Content instead of
   Content|example.orgoutput|\Content
  
   $c = curl_init(http://example.com );
   $st = fopen(php://memory, r+);
  
   curl_setopt($c, CURLOPT_FILE, $st);
  
   if(!curl_exec($c)) die (error: .curl_error($c));
  
   rewind($st);
   echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
   fclose($st);
  
  
   If I use a file stream instead it works as expected:
  
   $c = curl_init( http://example.com;);
  
   $file = /tmp/phptest.rand().;
   touch($file);
   $st = fopen($file, r+);
  
   curl_setopt($c, CURLOPT_FILE, $st);
  
   if(!curl_exec($c)) die (error: .curl_error($c));
  
   rewind($st);
   echo Content|.htmlspecialchars(stream_get_contents($st)).|/Content;
   fclose($st);
   unlink($file);

 im curious to know where you discovered
 php://memory
 was a valid stream; i looked through the online manual and found no
 reference to it.
 nor did i find anything from google.  i did encounter it in the php source,
 but with no
 useful documentation.
 a reference of all the streams that are valid with the php:// scheme would
 be helpful.

 getting to your problem, i think this could perhaps be a bug.
 you might file a bug report and post your code along with it; unless
 somebody has a
 better idea ;)

 -nathan


This reference to php:// streams you can find on
http://www.php.net/manual/en/wrappers.php.php . If nobody has a
solution I think I'll report it as a bug tomorrow.

Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php