[PHP-DEV] Strange problem with php_stream_read()
Hello all, I got a strange problem. I opened a network stream with my web server (localhost:80) and wrote a HTTP GET into stream and reading the HTTP RESPONSE. buff = (char *)emalloc(content_size); php_stream_read(http_stream, buff, content_size); where content_size is the Content-Length value in Response header. Problem is that when I return RETURN_STRING(buff,1); to userland. I'm getting a string with the content (response body) + some crap. length of string is more than content_size. for example: in a case content_size was 29; after php_stream_read() line, the strlen(buff) is returning 41. How is this possible? somewhere I read this php_stream_read() differs from other stream read functions in one surprising way. If the stream in use is not a plain files stream, only one call to the underlying stream implementation's read function will be made, even if more data was requested and more is actually available to return. This is a compromise to let packet-based protocols such as UDP function cleanly without blocking. I didn't clearly understand its meaning. Does it has anything to do with my results? Any help in understanding this behavious of php_stream_read() ? -- Mangol Smith
[PHP-DEV] How to enable debug for my extension?
Hi all, I'm trying to debug my extension.It says that PHP is built with debug flag, but my not my extenison. I used --enable-debug for PHP build. But, in the extension I wrote I can't find any configure option associated with debug in ./configure --help. I tried using the options --enable-debug and --with-debug options, but no result. PHP is giving a startup error while loading my extension. Any suggestions please. -- Mangol Smith
Re: [PHP-DEV] Re: Using Network functions.
Are you sure you even need to write your own extension? If you just want to do HTTP requests, then curl or HTTP extension should be sufficient. Nope, I'm developing an extension. In which I require this functionality. Its not the entire purpose of my extension. Just a part of the functionality.
[PHP-DEV] Using Network functions.
Hey guys, I just started hacking PHP. I want to use Netwok Functions. So far from the source code browsing I learnt that In PHP *obvious solution is not the right answer.* The obvious solution for implementing HTTP methods or any Network functions for that matter, is using socket(), connect(), send(), recv() with appropriate HTTP request which only works for *NIX systems. So, there must be some kind of wrappers over it make these Platform Independent. Though, I looked into the implementations of PHP_FUNCTION('php_get_contents'). I didn't get much of it. I din't see any socket functions in its implementation. I saw some kind of stream_* functions. (which was complete abstract to me). 1. Can any one help me in using Network functions? 2. What does streams has to do with this networking? Can it be done using streams? 3. In List of Supported Protocols/Wrappershttp://in2.php.net/manual/en/wrappers.phpits mentioned that Allows read-only access to files/resources via HTTP 1.0, using the HTTP GET method. This means isn't there any wrapper to use all HTTP methods. I'm concerned about HTTP PUT/POST (esp. PUT) method. How can I use that method? 4. what are the other alternatives (if any)?
[PHP-DEV] Re: Using Network functions.
Hey guys, someone suggested me to have a look at libcURL. I did, but its very complex. All I needed is lowlevel/network wrappers. like emalloc() pemalloc() as wrapper on malloc(). There might be some wrappers (platform independent used in php source code) which I can use to make a connection and then send HTTP requests. I hope this will be the simplest method.
Re: [PHP-DEV] Re: Using Network functions.
Hi, On Thu, Jun 26, 2008 at 8:55 AM, Jevon Wright [EMAIL PROTECTED] wrote: If you want to POST or do weird HTTP stuff, try the Curl extension. (Multiple platforms) Also look into PEAR, they have some socket stuff as well I think, as well as lots of other extensions that implement other protocols. But, doesn't this make my extension depend on Curl or any PEAR extension you are talking about? That is what I wan't to avoid. On Thu, Jun 26, 2008 at 8:27 AM, Larry Garfield [EMAIL PROTECTED] wrote: Why do you need raw string level control over the HTTP request? Wouldn't it be easier to use something that will handle all of the thousand edge cases and locking for you? Yeah, might be the only thing I want to avoid is my extension depending on other non standard (which are not shipped with PHP by default) extensions. Thats why I'm looking for lower level wrappers. Thats why I feel using CORE API.