* fixed a LOAD of mem-leaks
authorMichael Wallner <mike@php.net>
Sat, 19 Feb 2005 12:22:36 +0000 (12:22 +0000)
committerMichael Wallner <mike@php.net>
Sat, 19 Feb 2005 12:22:36 +0000 (12:22 +0000)
docs/functions.html
http.c
http_api.c
php_http.h
tests/030_send_data.phpt

index 46a2028ae27a83cdb0dec5a3ad8f467c7a7da302..eba8d60cefc2c3838f84a949e2bda4c8ef4c3c6c 100644 (file)
 <html>
 <head><title>Function Summary</title>
 <html>
 <head><title>Function Summary</title>
-<style>body { font-size: 80%; font-family: sans-serif; } h2 { color: #339; } pre { font-size: 1.2em; } pre br { display: none; } pre code br { display: block; } </style></head>
+<style>body { font-size: 80%; font-family: sans-serif; } h2 { color: #339; } pre { font-size: 1.2em; } </style></head>
 <body>
 <h1>http.c</h1>
 <body>
 <h1>http.c</h1>
-<h2 id="http_date">string http_date([int timestamp])</h2>
-<p>This function returns a valid HTTP date regarding RFC 822/1123<br />
+<h2>void HTTPi_Response::__construct(bool cache, bool gzip)</h2>
+<p></p>
+<h2>bool HTTPi_Response::setCache(bool cache)</h2>
+<p></p>
+<h2>bool HTTPi_Response::getCache()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setGzip(bool gzip)</h2>
+<p></p>
+<h2>bool HTTPi_Response::getGzip()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setCacheControl(string control[, bool raw = false])</h2>
+<p></p>
+<h2>string HTTPi_Response::getCacheControl()</h2>
+<p></p>
+<h2>bool HTTPi::setContentType(string content_type)</h2>
+<p></p>
+<h2>string HTTPi_Response::getContentType()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setContentDisposition(string filename[, bool inline = false])</h2>
+<p></p>
+<h2>array HTTPi_Response::getContentDisposition()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setETag(string etag)</h2>
+<p></p>
+<h2>string HTTPi_Response::getETag()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setData(string data)</h2>
+<p></p>
+<h2>string HTTPi_Response::getData()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setStream(resource stream)</h2>
+<p></p>
+<h2>resource HTTPi_Response::getStream()</h2>
+<p></p>
+<h2>bool HTTPi_Response::setFile(string file)</h2>
+<p></p>
+<h2>string HTTPi_Response::getFile()</h2>
+<p></p>
+<h2>int HTTPi_Response::getSize()</h2>
+<p></p>
+<h2>string http_date([int timestamp])</h2>
+<p>This function returns a valid HTTP date regarding RFC 822/1123
 looking like: "Wed, 22 Dec 2004 11:34:47 GMT"</p>
 looking like: "Wed, 22 Dec 2004 11:34:47 GMT"</p>
-<h2 id="http_absolute_uri">string http_absolute_uri(string url[, string proto])</h2>
-<p>This function returns an absolute URI constructed from url.<br />
-If the url is already abolute but a different proto was supplied,<br />
-only the proto part of the URI will be updated.  If url has no<br />
-path specified, the path of the current REQUEST_URI will be taken.<br />
-The host will be taken either from the Host HTTP header of the client<br />
-the SERVER_NAME or just localhost if prior are not available.</p><p>Some examples:<br />
-<pre><br />
-url = "page.php"                    => http://www.example.com/current/path/page.php<br />
-url = "/page.php"                   => http://www.example.com/page.php<br />
-url = "/page.php", proto = "https"  => https://www.example.com/page.php<br />
+<h2>string http_absolute_uri(string url[, string proto])</h2>
+<p>This function returns an absolute URI constructed from url.
+If the url is already abolute but a different proto was supplied,
+only the proto part of the URI will be updated.  If url has no
+path specified, the path of the current REQUEST_URI will be taken.
+The host will be taken either from the Host HTTP header of the client
+the SERVER_NAME or just localhost if prior are not available.</p><p>Some examples:
+<pre>
+url = "page.php"                    => http://www.example.com/current/path/page.php
+url = "/page.php"                   => http://www.example.com/page.php
+url = "/page.php", proto = "https"  => https://www.example.com/page.php
 </pre></p>
 </pre></p>
-<h2 id="http_negotiate_language">string http_negotiate_language(array supported[, string default = 'en-US'])</h2>
-<p>This function negotiates the clients preferred language based on its<br />
-Accept-Language HTTP header.  It returns the negotiated language or<br />
-the default language if none match.</p><p>The qualifier is recognized and languages without qualifier are rated highest.</p><p>The supported parameter is expected to be an array having<br />
-the supported languages as array values.</p><p>Example:<br />
-<pre><br />
-<code><font color="#000000"><br />
-<font color="#0000BB">&lt;?php<br />$langs </font><font color="#007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'en-US'</font><font color="#007700">,</font><font color="#FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'fr'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'fr-FR'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'de'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'de-DE'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'de-AT'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'de-CH'</font><font color="#007700">,<br />);<br />include </font><font color="#DD0000">'./langs/'</font><font color="#007700">. </font><font color="#0000BB">http_negotiate_language</font><font color="#007700">(</font><font color="#0000BB">$langs</font><font color="#007700">) .</font><font color="#DD0000">'.php'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font><br />
-</font><br />
-</code><br />
+<h2>string http_negotiate_language(array supported[, string default = 'en-US'])</h2>
+<p>This function negotiates the clients preferred language based on its
+Accept-Language HTTP header.  It returns the negotiated language or
+the default language if none match.</p><p>The qualifier is recognized and languages without qualifier are rated highest.</p><p>The supported parameter is expected to be an array having
+the supported languages as array values.</p><p>Example:
+<pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br />$langs </span><span style="color: #007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'en-US'</span><span style="color: #007700">,</span><span style="color: #FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'fr'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'fr-FR'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-AT'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'de-CH'</span><span style="color: #007700">,<br />);<br />include </span><span style="color: #DD0000">'./langs/'</span><span style="color: #007700">. </span><span style="color: #0000BB">http_negotiate_language</span><span style="color: #007700">(</span><span style="color: #0000BB">$langs</span><span style="color: #007700">) .</span><span style="color: #DD0000">'.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
+</span>
+</code>
 </pre></p>
 </pre></p>
-<h2 id="http_negotiate_charset">string http_negotiate_charset(array supported[, string default = 'iso-8859-1'])</h2>
-<p>This function negotiates the clients preferred charset based on its<br />
-Accept-Charset HTTP header.  It returns the negotiated charset or<br />
-the default charset if none match.</p><p>The qualifier is recognized and charset without qualifier are rated highest.</p><p>The supported parameter is expected to be an array having<br />
-the supported charsets as array values.</p><p>Example:<br />
-<pre><br />
-<code><font color="#000000"><br />
-<font color="#0000BB">&lt;?php<br />$charsets </font><font color="#007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'iso-8859-1'</font><font color="#007700">, </font><font color="#FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'iso-8859-2'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'iso-8859-15'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'utf-8'<br /></font><font color="#007700">);<br /></font><font color="#0000BB">$pref </font><font color="#007700">= </font><font color="#0000BB">http_negotiate_charset</font><font color="#007700">(</font><font color="#0000BB">$charsets</font><font color="#007700">);<br />if (!</font><font color="#0000BB">strcmp</font><font color="#007700">(</font><font color="#0000BB">$pref</font><font color="#007700">, </font><font color="#DD0000">'iso-8859-1'</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">iconv_set_encoding</font><font color="#007700">(</font><font color="#DD0000">'internal_encoding'</font><font color="#007700">, </font><font color="#DD0000">'iso-8859-1'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">iconv_set_encoding</font><font color="#007700">(</font><font color="#DD0000">'output_encoding'</font><font color="#007700">, </font><font color="#0000BB">$pref</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">ob_start</font><font color="#007700">(</font><font color="#DD0000">'ob_iconv_handler'</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?&gt;</font><br />
-</font><br />
-</code><br />
+<h2>string http_negotiate_charset(array supported[, string default = 'iso-8859-1'])</h2>
+<p>This function negotiates the clients preferred charset based on its
+Accept-Charset HTTP header.  It returns the negotiated charset or
+the default charset if none match.</p><p>The qualifier is recognized and charset without qualifier are rated highest.</p><p>The supported parameter is expected to be an array having
+the supported charsets as array values.</p><p>Example:
+<pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br />$charsets </span><span style="color: #007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">, </span><span style="color: #FF8000">// default<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-2'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'iso-8859-15'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'utf-8'<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pref </span><span style="color: #007700">= </span><span style="color: #0000BB">http_negotiate_charset</span><span style="color: #007700">(</span><span style="color: #0000BB">$charsets</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$pref</span><span style="color: #007700">, </span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">iconv_set_encoding</span><span style="color: #007700">(</span><span style="color: #DD0000">'internal_encoding'</span><span style="color: #007700">, </span><span style="color: #DD0000">'iso-8859-1'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">iconv_set_encoding</span><span style="color: #007700">(</span><span style="color: #DD0000">'output_encoding'</span><span style="color: #007700">, </span><span style="color: #0000BB">$pref</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ob_start</span><span style="color: #007700">(</span><span style="color: #DD0000">'ob_iconv_handler'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
+</span>
+</code>
 </pre></p>
 </pre></p>
-<h2 id="http_send_status">bool http_send_status(int status)</h2>
+<h2>bool http_send_status(int status)</h2>
 <p>Send HTTP status code.</p>
 <p>Send HTTP status code.</p>
-<h2 id="http_send_last_modified">bool http_send_last_modified([int timestamp])</h2>
-<p>This converts the given timestamp to a valid HTTP date and<br />
-sends it as "Last-Modified" HTTP header.  If timestamp is<br />
+<h2>bool http_send_last_modified([int timestamp])</h2>
+<p>This converts the given timestamp to a valid HTTP date and
+sends it as "Last-Modified" HTTP header.  If timestamp is
 omitted, current time is sent.</p>
 omitted, current time is sent.</p>
-<h2 id="http_match_modified">bool http_match_modified([int timestamp])</h2>
-<p>Matches the given timestamp against the clients "If-Modified-Since" resp.<br />
+<h2>bool http_match_modified([int timestamp])</h2>
+<p>Matches the given timestamp against the clients "If-Modified-Since" resp.
 "If-Unmodified-Since" HTTP headers.</p>
 "If-Unmodified-Since" HTTP headers.</p>
-<h2 id="http_match_etag">bool http_match_etag(string etag)</h2>
-<p>This matches the given ETag against the clients<br />
+<h2>bool http_match_etag(string etag)</h2>
+<p>This matches the given ETag against the clients
 "If-Match" resp. "If-None-Match" HTTP headers.</p>
 "If-Match" resp. "If-None-Match" HTTP headers.</p>
-<h2 id="http_cache_last_modified">bool http_cache_last_modified([int timestamp_or_expires]])</h2>
-<p>If timestamp_or_exires is greater than 0, it is handled as timestamp<br />
-and will be sent as date of last modification.  If it is 0 or omitted,<br />
-the current time will be sent as Last-Modified date.  If it's negative,<br />
-it is handled as expiration time in seconds, which means that if the<br />
-requested last modification date is not between the calculated timespan,<br />
+<h2>bool http_cache_last_modified([int timestamp_or_expires]])</h2>
+<p>If timestamp_or_exires is greater than 0, it is handled as timestamp
+and will be sent as date of last modification.  If it is 0 or omitted,
+the current time will be sent as Last-Modified date.  If it's negative,
+it is handled as expiration time in seconds, which means that if the
+requested last modification date is not between the calculated timespan,
 the Last-Modified header is updated and the actual body will be sent.</p>
 the Last-Modified header is updated and the actual body will be sent.</p>
-<h2 id="http_cache_etag">bool http_cache_etag([string etag])</h2>
-<p>This function attempts to cache the HTTP body based on an ETag,<br />
-either supplied or generated through calculation of the MD5<br />
-checksum of the output (uses output buffering).</p><p>If clients "If-None-Match" header matches the supplied/calculated<br />
-ETag, the body is considered cached on the clients side and<br />
+<h2>bool http_cache_etag([string etag])</h2>
+<p>This function attempts to cache the HTTP body based on an ETag,
+either supplied or generated through calculation of the MD5
+checksum of the output (uses output buffering).</p><p>If clients "If-None-Match" header matches the supplied/calculated
+ETag, the body is considered cached on the clients side and
 a "304 Not Modified" status code is issued.</p>
 a "304 Not Modified" status code is issued.</p>
-<h2 id="http_redirect">void http_redirect([string url[, array params[, bool session,[ bool permanent]]]])</h2>
-<p>Redirect to a given url.<br />
-The supplied url will be expanded with http_absolute_uri(), the params array will<br />
-be treated with http_build_query() and the session identification will be appended<br />
-if session is true.</p><p>Depending on permanent the redirection will be issued with a permanent<br />
-("301 Moved Permanently") or a temporary ("302 Found") redirection<br />
-status code.</p><p>To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,<br />
+<h2>string ob_httpetaghandler(string data, int mode)</h2>
+<p>For use with ob_start().
+Note that this has to be started as first output buffer.
+WARNING: Don't use with http_send_*().</p>
+<h2>void http_redirect([string url[, array params[, bool session,[ bool permanent]]]])</h2>
+<p>Redirect to a given url.
+The supplied url will be expanded with http_absolute_uri(), the params array will
+be treated with http_build_query() and the session identification will be appended
+if session is true.</p><p>Depending on permanent the redirection will be issued with a permanent
+("301 Moved Permanently") or a temporary ("302 Found") redirection
+status code.</p><p>To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,
 if the client doesn't redirect immediatly.</p>
 if the client doesn't redirect immediatly.</p>
-<h2 id="http_send_data">bool http_send_data(string data)</h2>
+<h2>bool http_send_data(string data)</h2>
 <p>Sends raw data with support for (multiple) range requests.</p>
 <p>Sends raw data with support for (multiple) range requests.</p>
-<h2 id="http_send_file">bool http_send_file(string file)</h2>
+<h2>bool http_send_file(string file)</h2>
 <p>Sends a file with support for (multiple) range requests.</p>
 <p>Sends a file with support for (multiple) range requests.</p>
-<h2 id="http_send_stream">bool http_send_stream(resource stream)</h2>
+<h2>bool http_send_stream(resource stream)</h2>
 <p>Sends an already opened stream with support for (multiple) range requests.</p>
 <p>Sends an already opened stream with support for (multiple) range requests.</p>
-<h2 id="http_content_type">bool http_content_type([string content_type = 'application/x-octetstream'])</h2>
+<h2>bool http_content_type([string content_type = 'application/x-octetstream'])</h2>
 <p>Sets the content type.</p>
 <p>Sets the content type.</p>
-<h2 id="http_content_disposition">bool http_content_disposition(string filename[, bool inline = false])</h2>
-<p>Set the Content Disposition.  The Content-Disposition header is very useful<br />
-if the data actually sent came from a file or something similar, that should<br />
+<h2>bool http_content_disposition(string filename[, bool inline = false])</h2>
+<p>Set the Content Disposition.  The Content-Disposition header is very useful
+if the data actually sent came from a file or something similar, that should
 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
 be "saved" by the client/user (i.e. by browsers "Save as..." popup window).</p>
-<h2 id="http_chunked_decode">string http_chunked_decode(string encoded)</h2>
-<p>This function decodes a string that was HTTP-chunked encoded.<br />
+<h2>string http_chunked_decode(string encoded)</h2>
+<p>This function decodes a string that was HTTP-chunked encoded.
 Returns false on failure.</p>
 Returns false on failure.</p>
-<h2 id="http_split_response">array http_split_response(string http_response)</h2>
-<p>This function splits an HTTP response into an array with headers and the<br />
-content body. The returned array may look simliar to the following example:</p><p><pre><br />
-array(<br />
-0 => array(<br />
-'Status' => '200 Ok',<br />
-'Content-Type' => 'text/plain',<br />
-'Content-Language' => 'en-US'<br />
-),<br />
-1 => "Hello World!"<br />
-);<br />
+<h2>array http_split_response(string http_response)</h2>
+<p>This function splits an HTTP response into an array with headers and the
+content body. The returned array may look simliar to the following example:</p><p><pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">array(<br /></span><span style="color: #0000BB">0 </span><span style="color: #007700">=&gt; array(<br /></span><span style="color: #DD0000">'Status' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'200 Ok'</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'Content-Type' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'Content-Language' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'en-US'<br /></span><span style="color: #007700">),<br /></span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Hello World!\"<br />);<br />?&gt;</span>
+</span>
+</code>
+</pre></p>
+<h2>array http_parse_headers(string header)</h2>
+<p></p>
+<h2>array http_get_request_headers(void)</h2>
+<p></p>
+<h2>string http_get(string url[, array options[, array &info]])</h2>
+<p>Performs an HTTP GET request on the supplied url.</p><p>The second parameter is expected to be an associative
+array where the following keys will be recognized:
+<pre>
+- redirect:         int, whether and how many redirects to follow
+- unrestrictedauth: bool, whether to continue sending credentials on
+redirects to a different host
+- proxyhost:        string, proxy host in "host[:port]" format
+- proxyport:        int, use another proxy port as specified in proxyhost
+- proxyauth:        string, proxy credentials in "user:pass" format
+- proxyauthtype:    int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM
+- httpauth:         string, http credentials in "user:pass" format
+- httpauthtype:     int, HTTP_AUTH_BASIC, DIGEST and/or NTLM
+- compress:         bool, whether to allow gzip/deflate content encoding
+(defaults to true)
+- port:             int, use another port as specified in the url
+- referer:          string, the referer to sends
+- useragent:        string, the user agent to send
+(defaults to PECL::HTTP/version (PHP/version)))
+- headers:          array, list of custom headers as associative array
+like array("header" => "value")
+- cookies:          array, list of cookies as associative array
+like array("cookie" => "value")
+- cookiestore:      string, path to a file where cookies are/will be stored
+</pre></p><p>The optional third parameter will be filled with some additional information
+in form af an associative array, if supplied, like the following example:
+<pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">array (<br /></span><span style="color: #DD0000">'effective_url' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'http://localhost'</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'response_code' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">403</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'total_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'namelookup_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.013</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'connect_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'pretransfer_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.014</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'size_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'size_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">202</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'speed_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">11882</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'speed_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'header_size' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">145</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'request_size' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">62</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'ssl_verifyresult' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'filetime' </span><span style="color: #007700">=&gt; -</span><span style="color: #0000BB">1</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'content_length_download' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">202</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'content_length_upload' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'starttransfer_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0.017</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'content_type' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'text/html; charset=iso-8859-1'</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'redirect_time' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'redirect_count' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'private' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'http_connectcode' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'httpauth_avail' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'proxyauth_avail' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />)<br /></span><span style="color: #0000BB">?&gt;</span>
+</span>
+</code>
 </pre></p>
 </pre></p>
-<h2 id="http_parse_headers">array http_parse_headers(string header) */</h2>
-<p></p>
-<h2 id="http_get">string http_get(string url[, array options[, array &info]])</h2>
-<p>Performs an HTTP GET request on the supplied url.</p><p>The second parameter is expected to be an associative<br />
-array where the following keys will be recognized:<br />
-<pre><br />
-- redirect:         int, whether and how many redirects to follow<br />
-- unrestrictedauth: bool, whether to continue sending credentials on<br />
-redirects to a different host<br />
-- proxyhost:        string, proxy host in "host[:port]" format<br />
-- proxyport:        int, use another proxy port as specified in proxyhost<br />
-- proxyauth:        string, proxy credentials in "user:pass" format<br />
-- proxyauthtype:    int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM<br />
-- httpauth:         string, http credentials in "user:pass" format<br />
-- httpauthtype:     int, HTTP_AUTH_BASIC, DIGEST and/or NTLM<br />
-- compress:         bool, whether to allow gzip/deflate content encoding<br />
-(defaults to true)<br />
-- port:             int, use another port as specified in the url<br />
-- referer:          string, the referer to sends<br />
-- useragent:        string, the user agent to send<br />
-(defaults to PECL::HTTP/version (PHP/version)))<br />
-- headers:          array, list of custom headers as associative array<br />
-like array("header" => "value")<br />
-- cookies:          array, list of cookies as associative array<br />
-like array("cookie" => "value")<br />
-- cookiestore:      string, path to a file where cookies are/will be stored<br />
-</pre></p><p>The optional third parameter will be filled with some additional information<br />
-in form af an associative array, if supplied (don't forget to initialize it<br />
-with NULL or array()).</p>
-<h2 id="http_head">string http_head(string url[, array options[, array &info]])</h2>
-<p>Performs an HTTP HEAD request on the suppied url.<br />
-Returns the HTTP response as string.<br />
+<h2>string http_head(string url[, array options[, array &info]])</h2>
+<p>Performs an HTTP HEAD request on the suppied url.
+Returns the HTTP response as string.
 See http_get() for a full list of available options.</p>
 See http_get() for a full list of available options.</p>
-<h2 id="http_post_data">string http_post_data(string url, string data[, array options[, &info]])</h2>
-<p>Performs an HTTP POST request, posting data.<br />
-Returns the HTTP response as string.<br />
+<h2>string http_post_data(string url, string data[, array options[, &info]])</h2>
+<p>Performs an HTTP POST request, posting data.
+Returns the HTTP response as string.
 See http_get() for a full list of available options.</p>
 See http_get() for a full list of available options.</p>
-<h2 id="http_post_array">string http_post_array(string url, array data[, array options[, array &info]])</h2>
-<p>Performs an HTTP POST request, posting www-form-urlencoded array data.<br />
-Returns the HTTP response as string.<br />
+<h2>string http_post_array(string url, array data[, array options[, array &info]])</h2>
+<p>Performs an HTTP POST request, posting www-form-urlencoded array data.
+Returns the HTTP response as string.
 See http_get() for a full list of available options.</p>
 See http_get() for a full list of available options.</p>
-<h2 id="http_auth_basic">bool http_auth_basic(string user, string pass[, string realm = "Restricted"])</h2>
-<p>Example:<br />
-<pre><br />
-<code><font color="#000000"><br />
-<font color="#0000BB">&lt;?php<br /></font><font color="#007700">if (!</font><font color="#0000BB">http_auth_basic</font><font color="#007700">(</font><font color="#DD0000">'mike'</font><font color="#007700">, </font><font color="#DD0000">'s3c|r3t'</font><font color="#007700">)) {<br />die(</font><font color="#DD0000">'&lt;h1&gt;Authorization failed!&lt;/h1&gt;'</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?&gt;</font><br />
-</font><br />
-</code><br />
+<h2>bool http_auth_basic(string user, string pass[, string realm = "Restricted"])</h2>
+<p>Example:
+<pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">http_auth_basic</span><span style="color: #007700">(</span><span style="color: #DD0000">'mike'</span><span style="color: #007700">, </span><span style="color: #DD0000">'s3c|r3t'</span><span style="color: #007700">)) {<br />die(</span><span style="color: #DD0000">'&lt;h1&gt;Authorization failed!&lt;/h1&gt;'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
+</span>
+</code>
 </pre></p>
 </pre></p>
-<h2 id="http_auth_basic_cb">bool http_auth_basic_cb(mixed callback[, string realm = "Restricted"])</h2>
-<p>Example:<br />
-<pre><br />
-<code><font color="#000000"><br />
-<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">auth_cb</font><font color="#007700">(</font><font color="#0000BB">$user</font><font color="#007700">, </font><font color="#0000BB">$pass</font><font color="#007700">)<br />{<br />global </font><font color="#0000BB">$db</font><font color="#007700">;<br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'SELECT pass FROM users WHERE user='</font><font color="#007700">. </font><font color="#0000BB">$db</font><font color="#007700">-&gt;</font><font color="#0000BB">quoteSmart</font><font color="#007700">(</font><font color="#0000BB">$user</font><font color="#007700">);<br />if (</font><font color="#0000BB">strlen</font><font color="#007700">(</font><font color="#0000BB">$realpass </font><font color="#007700">= </font><font color="#0000BB">$db</font><font color="#007700">-&gt;</font><font color="#0000BB">getOne</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">)) {<br />return </font><font color="#0000BB">$pass </font><font color="#007700">=== </font><font color="#0000BB">$realpass</font><font color="#007700">;<br />}<br />return </font><font color="#0000BB">false</font><font color="#007700">;<br />}<br /><br />if (!</font><font color="#0000BB">http_auth_basic_cb</font><font color="#007700">(</font><font color="#DD0000">'auth_cb'</font><font color="#007700">)) {<br />die(</font><font color="#DD0000">'&lt;h1&gt;Authorization failed&lt;/h1&gt;'</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?&gt;</font><br />
-</font><br />
-</code><br />
+<h2>bool http_auth_basic_cb(mixed callback[, string realm = "Restricted"])</h2>
+<p>Example:
+<pre>
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">auth_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$pass</span><span style="color: #007700">)<br />{<br />global </span><span style="color: #0000BB">$db</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #DD0000">'SELECT pass FROM users WHERE user='</span><span style="color: #007700">. </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">quoteSmart</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$realpass </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getOne</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) {<br />return </span><span style="color: #0000BB">$pass </span><span style="color: #007700">=== </span><span style="color: #0000BB">$realpass</span><span style="color: #007700">;<br />}<br />return </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />}<br /><br />if (!</span><span style="color: #0000BB">http_auth_basic_cb</span><span style="color: #007700">(</span><span style="color: #DD0000">'auth_cb'</span><span style="color: #007700">)) {<br />die(</span><span style="color: #DD0000">'&lt;h1&gt;Authorization failed&lt;/h1&gt;'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
+</span>
+</code>
 </pre></p>
 </pre></p>
-<hr noshade><p><b> Generated at: Thu, 10 Feb 2005 19:51:45 +0100</b></p>
+<hr noshade><p><b> Generated at: Thu, 17 Feb 2005 22:42:18 +0100</b></p>
 </body>
 </html>
 </body>
 </html>
diff --git a/http.c b/http.c
index ff61116a2470cb972ccb7fb2baa71a8672cd66dc..1fddaa4b23b0a74cc95bca932c7c58c92be277c1 100644 (file)
--- a/http.c
+++ b/http.c
@@ -155,6 +155,22 @@ function_entry http_functions[] = {
 #      define SET_PROP(o, n, z) zend_update_property(o->zo.ce, getThis(), (#n), sizeof(#n), (z) TSRMLS_CC)
 #      define GET_PROP(o, n) zend_read_property(o->zo.ce, getThis(), (#n), sizeof(#n), 0 TSRMLS_CC)
 
 #      define SET_PROP(o, n, z) zend_update_property(o->zo.ce, getThis(), (#n), sizeof(#n), (z) TSRMLS_CC)
 #      define GET_PROP(o, n) zend_read_property(o->zo.ce, getThis(), (#n), sizeof(#n), 0 TSRMLS_CC)
 
+#      define INIT_PARR(o, n) \
+       { \
+               zval *__tmp; \
+               MAKE_STD_ZVAL(__tmp); \
+               array_init(__tmp); \
+               SET_PROP(o, n, __tmp); \
+               o->n = __tmp; \
+       }
+
+#      define FREE_PARR(p) \
+       if (p) { \
+               zval_dtor(p); \
+               FREE_ZVAL(p); \
+               (p) = NULL; \
+       }
+
 /* {{{ HTTPi */
 
 zend_class_entry *httpi_ce;
 /* {{{ HTTPi */
 
 zend_class_entry *httpi_ce;
@@ -718,8 +734,12 @@ zend_class_entry *httpi_request_ce;
 static zend_object_handlers httpi_request_object_handlers;
 
 typedef struct {
 static zend_object_handlers httpi_request_object_handlers;
 
 typedef struct {
-       zend_object     zo;
+       zend_object zo;
        CURL *ch;
        CURL *ch;
+       
+       zval *options;
+       zval *responseInfo;
+       zval *responseData;
 } httpi_request_object;
 
 #define httpi_request_declare_default_properties(ce) _httpi_request_declare_default_properties(ce TSRMLS_CC)
 } httpi_request_object;
 
 #define httpi_request_declare_default_properties(ce) _httpi_request_declare_default_properties(ce TSRMLS_CC)
@@ -741,12 +761,18 @@ static inline void _httpi_request_declare_default_properties(zend_class_entry *c
 void _httpi_request_destroy_object(void *object, zend_object_handle handle TSRMLS_DC)
 {
        httpi_request_object *o = object;
 void _httpi_request_destroy_object(void *object, zend_object_handle handle TSRMLS_DC)
 {
        httpi_request_object *o = object;
+       
+       FREE_PARR(o->options);
+       FREE_PARR(o->responseInfo);
+       FREE_PARR(o->responseData);
+       
        if (OBJ_PROP(o)) {
                zend_hash_destroy(OBJ_PROP(o));
                FREE_HASHTABLE(OBJ_PROP(o));
        }
        if (o->ch) {
                curl_easy_cleanup(o->ch);
        if (OBJ_PROP(o)) {
                zend_hash_destroy(OBJ_PROP(o));
                FREE_HASHTABLE(OBJ_PROP(o));
        }
        if (o->ch) {
                curl_easy_cleanup(o->ch);
+               o->ch = NULL;
        }
        efree(o);
 }
        }
        efree(o);
 }
@@ -773,8 +799,8 @@ zend_object_value _httpi_request_new_object(zend_class_entry *ce TSRMLS_DC)
 
 zend_function_entry httpi_request_class_methods[] = {
        PHP_ME(HTTPi_Request, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
 
 zend_function_entry httpi_request_class_methods[] = {
        PHP_ME(HTTPi_Request, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-/*     PHP_ME(HTTPi_Request, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
-*/
+       PHP_ME(HTTPi_Request, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
+
        PHP_ME(HTTPi_Request, setOptions, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, getOptions, NULL, ZEND_ACC_PUBLIC)
 
        PHP_ME(HTTPi_Request, setOptions, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, getOptions, NULL, ZEND_ACC_PUBLIC)
 
@@ -823,10 +849,10 @@ PHP_METHOD(HTTPi_Request, __construct)
                return;
        }
 
                return;
        }
 
-       MAKE_STD_ZVAL(opts); array_init(opts); SET_PROP(obj, options, opts);
-       MAKE_STD_ZVAL(info); array_init(info); SET_PROP(obj, responseInfo, info);
-       MAKE_STD_ZVAL(resp); array_init(resp); SET_PROP(obj, responseData, resp);
-
+       INIT_PARR(obj, options);
+       INIT_PARR(obj, responseInfo);
+       INIT_PARR(obj, responseData);
+       
        if (URL) {
                UPD_PROP(obj, string, url, URL);
        }
        if (URL) {
                UPD_PROP(obj, string, url, URL);
        }
@@ -836,6 +862,30 @@ PHP_METHOD(HTTPi_Request, __construct)
 }
 /* }}} */
 
 }
 /* }}} */
 
+PHP_METHOD(HTTPi_Request, __destruct)
+{
+       zval *opts, *info, *resp;
+       getObject(httpi_request_object, obj);
+       
+       /*
+        * this never happens ???
+        */
+       
+       fprintf(stderr, "\n\n\nYAY, DESTRCUTOR CALLED!\n\n\n");
+       
+       opts = GET_PROP(obj, options);
+       zval_dtor(opts);
+       FREE_ZVAL(opts);
+       
+       info = GET_PROP(obj, reeponseInfo);
+       zval_dtor(info);
+       FREE_ZVAL(info);
+       
+       resp = GET_PROP(obj, responseData);
+       zval_dtor(resp);
+       FREE_ZVAL(resp);
+}
+
 /* {{{ proto bool HTTPi_Request::setOptions(array options)
  *
  */
 /* {{{ proto bool HTTPi_Request::setOptions(array options)
  *
  */
@@ -870,11 +920,10 @@ PHP_METHOD(HTTPi_Request, setOptions)
                                        continue;
                                }
                        }
                                        continue;
                                }
                        }
-                       zval_add_ref(opt);
-                       add_assoc_zval(old_opts, key, *opt);
+               zval_add_ref(opt);
+               add_assoc_zval(old_opts, key, *opt);
                }
        }
                }
        }
-       
        RETURN_TRUE;
 }
 /* }}} */
        RETURN_TRUE;
 }
 /* }}} */
@@ -1176,8 +1225,9 @@ PHP_METHOD(HTTPi_Request, getResponseInfo)
  */
 PHP_METHOD(HTTPi_Request, send)
 {
  */
 PHP_METHOD(HTTPi_Request, send)
 {
+       STATUS status = FAILURE;
        zval *meth, *URL, *qdata, *opts, *info, *resp;
        zval *meth, *URL, *qdata, *opts, *info, *resp;
-       char *response_data, *request_uri;
+       char *response_data, *request_uri, *uri;
        size_t response_len;
        getObject(httpi_request_object, obj);
 
        size_t response_len;
        getObject(httpi_request_object, obj);
 
@@ -1195,7 +1245,11 @@ PHP_METHOD(HTTPi_Request, send)
        info  = GET_PROP(obj, responseInfo);
        resp  = GET_PROP(obj, responseData);
 
        info  = GET_PROP(obj, responseInfo);
        resp  = GET_PROP(obj, responseData);
 
-       request_uri = http_absolute_uri(Z_STRVAL_P(URL), NULL);
+       uri = http_absolute_uri(Z_STRVAL_P(URL), NULL);
+       request_uri = ecalloc(HTTP_URI_MAXLEN + 1, 1);
+       strcpy(request_uri, uri);
+       efree(uri);
+       
        if (Z_STRLEN_P(qdata) && (strlen(request_uri) < HTTP_URI_MAXLEN)) {
                if (!strchr(request_uri, '?')) {
                        strcat(request_uri, "?");
        if (Z_STRLEN_P(qdata) && (strlen(request_uri) < HTTP_URI_MAXLEN)) {
                if (!strchr(request_uri, '?')) {
                        strcat(request_uri, "?");
@@ -1208,15 +1262,11 @@ PHP_METHOD(HTTPi_Request, send)
        switch (Z_LVAL_P(meth))
        {
                case HTTP_GET:
        switch (Z_LVAL_P(meth))
        {
                case HTTP_GET:
-                       if (SUCCESS != http_get_ex(obj->ch, request_uri, Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len)) {
-                               RETURN_FALSE;
-                       }
+                       status = http_get_ex(obj->ch, request_uri, Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len);
                break;
 
                case HTTP_HEAD:
                break;
 
                case HTTP_HEAD:
-                       if (SUCCESS != http_head_ex(obj->ch, request_uri, Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len)) {
-                               RETURN_FALSE;
-                       }
+                       status = http_head_ex(obj->ch, request_uri, Z_ARRVAL_P(opts), Z_ARRVAL_P(info), &response_data, &response_len);
                break;
 
                case HTTP_POST:
                break;
 
                case HTTP_POST:
@@ -1226,8 +1276,12 @@ PHP_METHOD(HTTPi_Request, send)
                break;
        }
 
                break;
        }
 
+       efree(request_uri);
+       
        /* final data handling */
        /* final data handling */
-       {
+       if (status != SUCCESS) {
+               RETURN_FALSE;
+       } else {
                zval *zheaders, *zbody;
 
                MAKE_STD_ZVAL(zbody);
                zval *zheaders, *zbody;
 
                MAKE_STD_ZVAL(zbody);
@@ -1238,11 +1292,14 @@ PHP_METHOD(HTTPi_Request, send)
                        zval_dtor(zheaders);
                        efree(zheaders),
                        efree(zbody);
                        zval_dtor(zheaders);
                        efree(zheaders),
                        efree(zbody);
+                       efree(response_data);
                        RETURN_FALSE;
                }
 
                add_assoc_zval(resp, "headers", zheaders);
                add_assoc_zval(resp, "body", zbody);
                        RETURN_FALSE;
                }
 
                add_assoc_zval(resp, "headers", zheaders);
                add_assoc_zval(resp, "body", zbody);
+               
+               efree(response_data);
 
                RETURN_TRUE;
        }
 
                RETURN_TRUE;
        }
index a5b898d8f6931ce91d6a33ff269686b85d4e910f..b16da00430999c182e177d656de9da84a0de02f9 100644 (file)
@@ -563,7 +563,7 @@ static inline void _http_curl_setopts(CURL *ch, const char *url, HashTable *opti
 /* {{{ static inline char *http_curl_getinfoname(CURLINFO) */
 static inline char *_http_curl_getinfoname(CURLINFO i TSRMLS_DC)
 {
 /* {{{ static inline char *http_curl_getinfoname(CURLINFO) */
 static inline char *_http_curl_getinfoname(CURLINFO i TSRMLS_DC)
 {
-#define CASE(I) case CURLINFO_ ##I : return pretty_key(estrdup( #I ), strlen(#I), 0, 0)
+#define CASE(I) case CURLINFO_ ##I : { static char I[] = #I; return pretty_key(I, sizeof(#I)-1, 0, 0); }
        switch (i)
        {
                /* CURLINFO_EFFECTIVE_URL                       =       CURLINFO_STRING +1, */
        switch (i)
        {
                /* CURLINFO_EFFECTIVE_URL                       =       CURLINFO_STRING +1, */
index 6251c98f6aad1c4189cbafc9d8f84c297050ee26..b2bdbe24b63d408c728ac57afc9e3e7d23ad2593 100644 (file)
@@ -110,8 +110,8 @@ PHP_METHOD(HTTPi_Response, send);
 
 #ifdef HTTP_HAVE_CURL
 
 
 #ifdef HTTP_HAVE_CURL
 
-PHP_METHOD(HTTPi_Request, __construct);/*
-PHP_METHOD(HTTPi_Request, __destruct);*/
+PHP_METHOD(HTTPi_Request, __construct);
+PHP_METHOD(HTTPi_Request, __destruct);
 PHP_METHOD(HTTPi_Request, setOptions);
 PHP_METHOD(HTTPi_Request, getOptions);
 PHP_METHOD(HTTPi_Request, setMethod);
 PHP_METHOD(HTTPi_Request, setOptions);
 PHP_METHOD(HTTPi_Request, getOptions);
 PHP_METHOD(HTTPi_Request, setMethod);
index 301d45fe7b72a7be6fdf9219d30ff32d161c98f0..8db55cfd5241c0aaa2bbde85357521f6bae1353f 100644 (file)
@@ -7,7 +7,7 @@ strncasecmp(PHP_SAPI, 'CLI', 3) or die('cannot run tests with CLI');
 ?>
 --FILE--
 <?php
 ?>
 --FILE--
 <?php
-http_content_type('text/plain');
+http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1));
 ?>
 --EXPECTREGEX--
 http_send_data(str_repeat('123abc', 1));
 ?>
 --EXPECTREGEX--