2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
15 #define HTTP_WANT_SAPI
16 #define HTTP_WANT_CURL
17 #define HTTP_WANT_ZLIB
21 #include "ext/standard/php_string.h"
22 #include "zend_operators.h"
24 #ifdef HAVE_PHP_SESSION
25 # include "ext/session/php_session.h"
28 #include "php_http_api.h"
29 #include "php_http_cache_api.h"
30 #include "php_http_date_api.h"
31 #include "php_http_encoding_api.h"
32 #include "php_http_headers_api.h"
33 #include "php_http_message_api.h"
34 #include "php_http_request_api.h"
35 #include "php_http_request_method_api.h"
36 #include "php_http_send_api.h"
37 #include "php_http_url_api.h"
39 /* {{{ proto string http_date([int timestamp])
41 * Compose a valid HTTP date regarding RFC 822/1123
42 * looking like: "Wed, 22 Dec 2004 11:34:47 GMT"
44 * Takes an optional unix timestamp as parameter.
46 * Returns the HTTP date as string.
48 PHP_FUNCTION(http_date
)
52 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &t
) != SUCCESS
) {
57 t
= (long) HTTP_GET_REQUEST_TIME();
60 RETURN_STRING(http_date(t
), 0);
64 /* {{{ proto string http_build_url(mixed url[, mixed parts[, array &new_url]])
66 * Returns the new URL as string on success or FALSE on failure.
68 PHP_FUNCTION(http_build_url
)
72 zval
*z_old_url
= NULL
, *z_new_url
= NULL
, *z_composed_url
= NULL
;
73 php_url
*old_url
= NULL
, *new_url
= NULL
, *composed_url
= NULL
;
75 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/|z/z", &z_old_url
, &z_new_url
, &z_composed_url
) != SUCCESS
) {
80 if (Z_TYPE_P(z_new_url
) == IS_ARRAY
|| Z_TYPE_P(z_new_url
) == IS_OBJECT
) {
81 new_url
= array2url(HASH_OF(z_new_url
));
83 convert_to_string(z_new_url
);
84 if (!(new_url
= php_url_parse_ex(Z_STRVAL_P(z_new_url
), Z_STRLEN_P(z_new_url
)))) {
85 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_new_url
));
91 if (Z_TYPE_P(z_old_url
) == IS_ARRAY
|| Z_TYPE_P(z_old_url
) == IS_OBJECT
) {
92 old_url
= array2url(HASH_OF(z_old_url
));
94 convert_to_string(z_old_url
);
95 if (!(old_url
= php_url_parse_ex(Z_STRVAL_P(z_old_url
), Z_STRLEN_P(z_old_url
)))) {
97 php_url_free(new_url
);
99 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_old_url
));
104 if (z_composed_url
) {
105 http_build_url(old_url
, new_url
, &composed_url
, &url_str
, &url_len
);
107 zval_dtor(z_composed_url
);
108 array_init(z_composed_url
);
109 if (composed_url
->scheme
) {
110 add_assoc_string(z_composed_url
, "scheme", composed_url
->scheme
, 1);
112 if (composed_url
->user
) {
113 add_assoc_string(z_composed_url
, "user", composed_url
->user
, 1);
115 if (composed_url
->pass
) {
116 add_assoc_string(z_composed_url
, "pass", composed_url
->pass
, 1);
118 if (composed_url
->host
) {
119 add_assoc_string(z_composed_url
, "host", composed_url
->host
, 1);
121 if (composed_url
->port
) {
122 add_assoc_long(z_composed_url
, "port", composed_url
->port
);
124 if (composed_url
->path
) {
125 add_assoc_string(z_composed_url
, "path", composed_url
->path
, 1);
127 if (composed_url
->query
) {
128 add_assoc_string(z_composed_url
, "query", composed_url
->query
, 1);
130 if (composed_url
->fragment
) {
131 add_assoc_string(z_composed_url
, "fragment", composed_url
->fragment
, 1);
133 php_url_free(composed_url
);
135 http_build_url(old_url
, new_url
, NULL
, &url_str
, &url_len
);
139 php_url_free(new_url
);
141 php_url_free(old_url
);
143 RETURN_STRINGL(url_str
, url_len
, 0);
147 #define HTTP_DO_NEGOTIATE(type, supported, rs_array) \
150 if ((result = http_negotiate_ ##type(supported))) { \
155 if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
156 RETVAL_STRINGL(key, key_len-1, 0); \
162 zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \
165 zend_hash_destroy(result); \
166 FREE_HASHTABLE(result); \
171 zend_hash_internal_pointer_reset(Z_ARRVAL_P(supported)); \
172 if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(supported), (void **) &value)) { \
173 RETVAL_ZVAL(*value, 1, 0); \
182 FOREACH_VAL(pos, supported, value) { \
183 convert_to_string_ex(value); \
184 add_assoc_double(rs_array, Z_STRVAL_PP(value), 1.0); \
191 /* {{{ proto string http_negotiate_language(array supported[, array &result])
193 * This function negotiates the clients preferred language based on its
194 * Accept-Language HTTP header. The qualifier is recognized and languages
195 * without qualifier are rated highest. The qualifier will be decreased by
196 * 10% for partial matches (i.e. matching primary language).
198 * Expects an array as parameter cotaining the supported languages as values.
199 * If the optional second parameter is supplied, it will be filled with an
200 * array containing the negotiation results.
202 * Returns the negotiated language or the default language (i.e. first array entry)
218 * include './langs/'. http_negotiate_language($langs, $result) .'.php';
224 PHP_FUNCTION(http_negotiate_language
)
226 zval
*supported
, *rs_array
= NULL
;
228 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
234 array_init(rs_array
);
237 HTTP_DO_NEGOTIATE(language
, supported
, rs_array
);
241 /* {{{ proto string http_negotiate_charset(array supported[, array &result])
243 * This function negotiates the clients preferred charset based on its
244 * Accept-Charset HTTP header. The qualifier is recognized and charsets
245 * without qualifier are rated highest.
247 * Expects an array as parameter cotaining the supported charsets as values.
248 * If the optional second parameter is supplied, it will be filled with an
249 * array containing the negotiation results.
251 * Returns the negotiated charset or the default charset (i.e. first array entry)
258 * 'iso-8859-1', // default
264 * $pref = http_negotiate_charset($charsets, $result);
266 * if (strcmp($pref, 'iso-8859-1')) {
267 * iconv_set_encoding('internal_encoding', 'iso-8859-1');
268 * iconv_set_encoding('output_encoding', $pref);
269 * ob_start('ob_iconv_handler');
276 PHP_FUNCTION(http_negotiate_charset
)
278 zval
*supported
, *rs_array
= NULL
;
280 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
286 array_init(rs_array
);
289 HTTP_DO_NEGOTIATE(charset
, supported
, rs_array
);
293 /* {{{ proto string http_negotiate_ctype(array supported[, array &result])
295 * This function negotiates the clients preferred content type based on its
296 * Accept HTTP header. The qualifier is recognized and content types
297 * without qualifier are rated highest.
299 * Expects an array as parameter cotaining the supported content types as values.
300 * If the optional second parameter is supplied, it will be filled with an
301 * array containing the negotiation results.
303 * Returns the negotiated content type or the default content type
304 * (i.e. first array entry) if none match.
309 * $ctypes = array('application/xhtml+xml', 'text/html');
310 * http_send_content_type(http_negotiate_content_type($ctypes));
314 PHP_FUNCTION(http_negotiate_content_type
)
316 zval
*supported
, *rs_array
= NULL
;
318 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
)) {
324 array_init(rs_array
);
327 HTTP_DO_NEGOTIATE(content_type
, supported
, rs_array
);
331 /* {{{ proto bool http_send_status(int status)
333 * Send HTTP status code.
335 * Expects an HTTP status code as parameter.
337 * Returns TRUE on success or FALSE on failure.
339 PHP_FUNCTION(http_send_status
)
343 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &status
) != SUCCESS
) {
346 if (status
< 100 || status
> 510) {
347 http_error_ex(HE_WARNING
, HTTP_E_HEADER
, "Invalid HTTP status code (100-510): %d", status
);
351 RETURN_SUCCESS(http_send_status(status
));
355 /* {{{ proto bool http_send_last_modified([int timestamp])
357 * Send a "Last-Modified" header with a valid HTTP date.
359 * Accepts a unix timestamp, converts it to a valid HTTP date and
360 * sends it as "Last-Modified" HTTP header. If timestamp is
361 * omitted, the current time will be sent.
363 * Returns TRUE on success or FALSE on failure.
365 PHP_FUNCTION(http_send_last_modified
)
369 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &t
) != SUCCESS
) {
374 t
= (long) HTTP_GET_REQUEST_TIME();
377 RETURN_SUCCESS(http_send_last_modified(t
));
381 /* {{{ proto bool http_send_content_type([string content_type = 'application/x-octetstream'])
383 * Send the Content-Type of the sent entity. This is particularly important
384 * if you use the http_send() API.
386 * Accepts an optional string parameter containing the desired content type
387 * (primary/secondary).
389 * Returns TRUE on success or FALSE on failure.
391 PHP_FUNCTION(http_send_content_type
)
393 char *ct
= "application/x-octetstream";
394 int ct_len
= lenof("application/x-octetstream");
396 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &ct
, &ct_len
) != SUCCESS
) {
400 RETURN_SUCCESS(http_send_content_type(ct
, ct_len
));
404 /* {{{ proto bool http_send_content_disposition(string filename[, bool inline = false])
406 * Send the Content-Disposition. The Content-Disposition header is very useful
407 * if the data actually sent came from a file or something similar, that should
408 * be "saved" by the client/user (i.e. by browsers "Save as..." popup window).
410 * Expects a string parameter specifying the file name the "Save as..." dialogue
411 * should display. Optionally accepts a bool parameter, which, if set to true
412 * and the user agent knows how to handle the content type, will probably not
413 * cause the popup window to be shown.
415 * Returns TRUE on success or FALSE on failure.
417 PHP_FUNCTION(http_send_content_disposition
)
421 zend_bool send_inline
= 0;
423 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &filename
, &f_len
, &send_inline
) != SUCCESS
) {
426 RETURN_SUCCESS(http_send_content_disposition(filename
, f_len
, send_inline
));
430 /* {{{ proto bool http_match_modified([int timestamp[, bool for_range = false]])
432 * Matches the given unix timestamp against the clients "If-Modified-Since"
433 * resp. "If-Unmodified-Since" HTTP headers.
435 * Accepts a unix timestamp which should be matched. Optionally accepts an
436 * additional bool parameter, which if set to true will check the header
437 * usually used to validate HTTP ranges. If timestamp is omitted, the
438 * current time will be used.
440 * Returns TRUE if timestamp represents an earlier date than the header,
443 PHP_FUNCTION(http_match_modified
)
446 zend_bool for_range
= 0;
448 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|lb", &t
, &for_range
) != SUCCESS
) {
452 // current time if not supplied (senseless though)
454 t
= (long) HTTP_GET_REQUEST_TIME();
458 RETURN_BOOL(http_match_last_modified("HTTP_IF_UNMODIFIED_SINCE", t
));
460 RETURN_BOOL(http_match_last_modified("HTTP_IF_MODIFIED_SINCE", t
));
464 /* {{{ proto bool http_match_etag(string etag[, bool for_range = false])
466 * Matches the given ETag against the clients "If-Match" resp.
467 * "If-None-Match" HTTP headers.
469 * Expects a string parameter containing the ETag to compare. Optionally
470 * accepts a bool parameter, which, if set to true, will check the header
471 * usually used to validate HTTP ranges.
473 * Retuns TRUE if ETag matches or the header contained the asterisk ("*"),
476 PHP_FUNCTION(http_match_etag
)
480 zend_bool for_range
= 0;
482 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &etag
, &etag_len
, &for_range
) != SUCCESS
) {
487 RETURN_BOOL(http_match_etag("HTTP_IF_MATCH", etag
));
489 RETURN_BOOL(http_match_etag("HTTP_IF_NONE_MATCH", etag
));
493 /* {{{ proto bool http_cache_last_modified([int timestamp_or_expires]])
495 * Attempts to cache the sent entity by its last modification date.
497 * Accepts a unix timestamp as parameter which is handled as follows:
499 * If timestamp_or_expires is greater than 0, it is handled as timestamp
500 * and will be sent as date of last modification. If it is 0 or omitted,
501 * the current time will be sent as Last-Modified date. If it's negative,
502 * it is handled as expiration time in seconds, which means that if the
503 * requested last modification date is not between the calculated timespan,
504 * the Last-Modified header is updated and the actual body will be sent.
506 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
508 * A log entry will be written to the cache log if the INI entry
509 * http.cache_log is set and the cache attempt was successful.
511 PHP_FUNCTION(http_cache_last_modified
)
513 long last_modified
= 0, send_modified
= 0, t
;
516 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &last_modified
) != SUCCESS
) {
520 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
522 t
= (long) HTTP_GET_REQUEST_TIME();
525 if (!last_modified
) {
526 /* does the client have? (att: caching "forever") */
527 if ((zlm
= http_get_server_var("HTTP_IF_MODIFIED_SINCE"))) {
528 last_modified
= send_modified
= http_parse_date(Z_STRVAL_P(zlm
));
529 /* send current time */
533 /* negative value is supposed to be expiration time */
534 } else if (last_modified
< 0) {
537 /* send supplied time explicitly */
539 send_modified
= last_modified
;
542 RETURN_SUCCESS(http_cache_last_modified(last_modified
, send_modified
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
546 /* {{{ proto bool http_cache_etag([string etag])
548 * Attempts to cache the sent entity by its ETag, either supplied or generated
549 * by the hash algorythm specified by the INI setting "http.etag_mode".
551 * If the clients "If-None-Match" header matches the supplied/calculated
552 * ETag, the body is considered cached on the clients side and
553 * a "304 Not Modified" status code is issued.
555 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
557 * A log entry is written to the cache log if the INI entry
558 * "http.cache_log" is set and the cache attempt was successful.
560 PHP_FUNCTION(http_cache_etag
)
565 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &etag
, &etag_len
) != SUCCESS
) {
569 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
571 RETURN_SUCCESS(http_cache_etag(etag
, etag_len
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
575 /* {{{ proto string ob_etaghandler(string data, int mode)
577 * For use with ob_start(). Output buffer handler generating an ETag with
578 * the hash algorythm specified with the INI setting "http.etag_mode".
580 PHP_FUNCTION(ob_etaghandler
)
586 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
590 Z_TYPE_P(return_value
) = IS_STRING
;
591 http_ob_etaghandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
595 /* {{{ proto void http_throttle(double sec[, int bytes = 40960])
597 * Sets the throttle delay and send buffer size for use with http_send() API.
598 * Provides a basic throttling mechanism, which will yield the current process
599 * resp. thread until the entity has been completely sent, though.
601 * Expects a double parameter specifying the seconds too sleep() after
602 * each chunk sent. Additionally accepts an optional int parameter
603 * representing the chunk size in bytes.
609 * # http_throttle(1, 20000);
610 * # http_throttle(0.5, 10000);
611 * # http_throttle(0.1, 2000);
612 * http_send_file('document.pdf');
616 PHP_FUNCTION(http_throttle
)
618 long chunk_size
= HTTP_SENDBUF_SIZE
;
621 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "d|l", &interval
, &chunk_size
)) {
625 HTTP_G(send
).throttle_delay
= interval
;
626 HTTP_G(send
).buffer_size
= chunk_size
;
630 /* {{{ proto void http_redirect([string url[, array params[, bool session = false[, int status = 302]]]])
632 * Redirect to the given url.
634 * The supplied url will be expanded with http_build_url(), the params array will
635 * be treated with http_build_query() and the session identification will be appended
636 * if session is true.
638 * The HTTP response code will be set according to status.
639 * You can use one of the following constants for convenience:
640 * - HTTP_REDIRECT 302 Found for GET/HEAD, else 303 See Other
641 * - HTTP_REDIRECT_PERM 301 Moved Permanently
642 * - HTTP_REDIRECT_FOUND 302 Found
643 * - HTTP_REDIRECT_POST 303 See Other
644 * - HTTP_REDIRECT_PROXY 305 Use Proxy
645 * - HTTP_REDIRECT_TEMP 307 Temporary Redirect
647 * Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
648 * for which redirect response code to use in which situation.
650 * To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed,
651 * if the client doesn't redirect immediatly, and the request method was
652 * another one than HEAD.
654 * Returns FALSE on failure, or *exits* on success.
656 * A log entry will be written to the redirect log, if the INI entry
657 * "http.redirect_log" is set and the redirect attempt was successful.
659 PHP_FUNCTION(http_redirect
)
662 size_t query_len
= 0;
663 zend_bool session
= 0, free_params
= 0;
665 long status
= HTTP_REDIRECT
;
666 char *query
= NULL
, *url
= NULL
, *URI
, *LOC
, *RED
= NULL
;
668 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|sa!/bl", &url
, &url_len
, ¶ms
, &session
, &status
) != SUCCESS
) {
672 #ifdef HAVE_PHP_SESSION
673 /* append session info */
677 MAKE_STD_ZVAL(params
);
680 if (PS(session_status
) == php_session_active
) {
681 if (add_assoc_string(params
, PS(session_name
), PS(id
), 1) != SUCCESS
) {
682 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Could not append session information");
688 /* treat params array with http_build_query() */
690 if (SUCCESS
!= http_urlencode_hash_ex(Z_ARRVAL_P(params
), 0, NULL
, 0, &query
, &query_len
)) {
702 URI
= http_absolute_url(url
);
705 spprintf(&LOC
, 0, "Location: %s?%s", URI
, query
);
707 spprintf(&RED
, 0, "Redirecting to <a href=\"%s?%s\">%s?%s</a>.\n", URI
, query
, URI
, query
);
710 spprintf(&LOC
, 0, "Location: %s", URI
);
712 spprintf(&RED
, 0, "Redirecting to <a href=\"%s\">%s</a>.\n", URI
, URI
);
728 RETVAL_SUCCESS(http_send_status_header(status
, LOC
));
733 case HTTP_REDIRECT_PERM
:
734 case HTTP_REDIRECT_FOUND
:
735 case HTTP_REDIRECT_POST
:
736 case HTTP_REDIRECT_PROXY
:
737 case HTTP_REDIRECT_TEMP
:
742 http_error_ex(HE_NOTICE
, HTTP_E_RUNTIME
, "Unsupported redirection status code: %ld", status
);
744 if ( SG(request_info
).request_method
&&
745 strcasecmp(SG(request_info
).request_method
, "HEAD") &&
746 strcasecmp(SG(request_info
).request_method
, "GET")) {
747 status
= HTTP_REDIRECT_POST
;
749 status
= HTTP_REDIRECT_FOUND
;
754 RETURN_SUCCESS(http_exit_ex(status
, LOC
, RED
, 1));
758 /* {{{ proto bool http_send_data(string data)
760 * Sends raw data with support for (multiple) range requests.
762 * Retursn TRUE on success, or FALSE on failure.
764 PHP_FUNCTION(http_send_data
)
768 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z", &zdata
) != SUCCESS
) {
772 convert_to_string_ex(&zdata
);
773 RETURN_SUCCESS(http_send_data(Z_STRVAL_P(zdata
), Z_STRLEN_P(zdata
)));
777 /* {{{ proto bool http_send_file(string file)
779 * Sends a file with support for (multiple) range requests.
781 * Expects a string parameter referencing the file to send.
783 * Returns TRUE on success, or FALSE on failure.
785 PHP_FUNCTION(http_send_file
)
790 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &file
, &flen
) != SUCCESS
) {
797 RETURN_SUCCESS(http_send_file(file
));
801 /* {{{ proto bool http_send_stream(resource stream)
803 * Sends an already opened stream with support for (multiple) range requests.
805 * Expects a resource parameter referncing the stream to read from.
807 * Returns TRUE on success, or FALSE on failure.
809 PHP_FUNCTION(http_send_stream
)
814 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &zstream
) != SUCCESS
) {
818 php_stream_from_zval(file
, &zstream
);
819 RETURN_SUCCESS(http_send_stream(file
));
823 /* {{{ proto string http_chunked_decode(string encoded)
825 * Decodes a string that was HTTP-chunked encoded.
827 * Expects a chunked encoded string as parameter.
829 * Returns the decoded string on success or FALSE on failure.
831 PHP_FUNCTION(http_chunked_decode
)
833 char *encoded
= NULL
, *decoded
= NULL
;
834 size_t decoded_len
= 0;
837 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &encoded
, &encoded_len
) != SUCCESS
) {
841 if (NULL
!= http_encoding_dechunk(encoded
, encoded_len
, &decoded
, &decoded_len
)) {
842 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
849 /* {{{ proto object http_parse_message(string message)
851 * Parses (a) http_message(s) into a simple recursive object structure.
853 * Expects a string parameter containing a single HTTP message or
854 * several consecutive HTTP messages.
856 * Returns an hierachical object structure of the parsed messages.
861 * print_r(http_parse_message(http_get(URL, array('redirect' => 3)));
866 * [httpVersion] => 1.1
867 * [responseCode] => 200
870 * [Content-Length] => 3
874 * [parentMessage] => stdClass object
877 * [httpVersion] => 1.1
878 * [responseCode] => 302
881 * [Content-Length] => 0
885 * [parentMessage] => ...
891 PHP_FUNCTION(http_parse_message
)
895 http_message
*msg
= NULL
;
897 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &message
, &message_len
)) {
901 if ((msg
= http_message_parse(message
, message_len
))) {
902 object_init(return_value
);
903 http_message_tostruct_recursive(msg
, return_value
);
904 http_message_free(&msg
);
911 /* {{{ proto array http_parse_headers(string header)
913 * Parses HTTP headers into an associative array.
915 * Expects a string parameter containing HTTP headers.
917 * Returns an array on success, or FALSE on failure.
922 * $headers = "content-type: text/html; charset=UTF-8\r\n".
923 * "Server: Funky/1.0\r\n".
924 * "Set-Cookie: foo=bar\r\n".
925 * "Set-Cookie: baz=quux\r\n".
926 * "Folded: works\r\n\ttoo\r\n";
927 * print_r(http_parse_headers($headers));
931 * [Content-Type] => text/html; chatset=UTF-8
932 * [Server] => Funky/1.0
933 * [Set-Cookie] => Array
944 PHP_FUNCTION(http_parse_headers
)
949 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &header
, &header_len
)) {
953 array_init(return_value
);
954 if (SUCCESS
!= http_parse_headers(header
, return_value
)) {
955 zval_dtor(return_value
);
961 /* {{{ proto object http_parse_cookie(string cookie)
963 * Parses HTTP cookies like sent in a response into a struct.
965 * Expects a string as parameter containing the value of a Set-Cookie response header.
967 * Returns an stdClass object with the cookie params as properties on success or FALSE on failure.
972 * print_r(http_parse_cookie("foo=bar; path=/"));
983 PHP_FUNCTION(http_parse_cookie
)
988 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &cookie
, &cookie_len
)) {
992 object_init(return_value
);
993 if (SUCCESS
!= http_parse_cookie(cookie
, HASH_OF(return_value
))) {
994 zval_dtor(return_value
);
999 /* {{{ proto array http_get_request_headers(void)
1001 * Get a list of incoming HTTP headers.
1003 * Returns an associative array of incoming request headers.
1005 PHP_FUNCTION(http_get_request_headers
)
1009 array_init(return_value
);
1010 http_get_request_headers(return_value
);
1014 /* {{{ proto string http_get_request_body(void)
1016 * Get the raw request body (e.g. POST or PUT data).
1018 * This function can not be used after http_get_request_body_stream()
1019 * if the request method was another than POST.
1021 * Returns the raw request body as string on success or NULL on failure.
1023 PHP_FUNCTION(http_get_request_body
)
1030 if (SUCCESS
== http_get_request_body(&body
, &length
)) {
1031 RETURN_STRINGL(body
, (int) length
, 0);
1038 /* {{{ proto resource http_get_request_body_stream(void)
1040 * Create a stream to read the raw request body (e.g. POST or PUT data).
1042 * This function can only be used once if the request method was another than POST.
1044 * Returns the raw request body as stream on success or NULL on failure.
1046 PHP_FUNCTION(http_get_request_body_stream
)
1052 if ((s
= http_get_request_body_stream())) {
1053 php_stream_to_zval(s
, return_value
);
1055 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Failed to create request body stream");
1061 /* {{{ proto bool http_match_request_header(string header, string value[, bool match_case = false])
1063 * Match an incoming HTTP header.
1065 * Expects two string parameters representing the header name (case-insensitive)
1066 * and the header value that should be compared. The case sensitivity of the
1067 * header value depends on the additional optional bool parameter accepted.
1069 * Returns TRUE if header value matches, else FALSE.
1071 PHP_FUNCTION(http_match_request_header
)
1073 char *header
, *value
;
1074 int header_len
, value_len
;
1075 zend_bool match_case
= 0;
1077 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|b", &header
, &header_len
, &value
, &value_len
, &match_case
)) {
1081 RETURN_BOOL(http_match_request_header_ex(header
, value
, match_case
));
1086 #ifdef HTTP_HAVE_CURL
1088 #define RETVAL_RESPONSE_OR_BODY(request) \
1092 /* check if only the body should be returned */ \
1093 if (options && (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), "bodyonly", sizeof("bodyonly"), (void **) &bodyonly)) && zval_is_true(*bodyonly)) { \
1094 http_message *msg = http_message_parse(PHPSTR_VAL(&request.conv.response), PHPSTR_LEN(&request.conv.response)); \
1097 RETVAL_STRINGL(PHPSTR_VAL(&msg->body), PHPSTR_LEN(&msg->body), 1); \
1098 http_message_free(&msg); \
1101 RETVAL_STRINGL(request.conv.response.data, request.conv.response.used, 1); \
1105 /* {{{ proto string http_get(string url[, array options[, array &info]])
1107 * Performs an HTTP GET request on the supplied url.
1109 * The second parameter, if set, is expected to be an associative
1110 * array where the following keys will be recognized:
1112 * - redirect: int, whether and how many redirects to follow
1113 * - unrestrictedauth: bool, whether to continue sending credentials on
1114 * redirects to a different host
1115 * - proxyhost: string, proxy host in "host[:port]" format
1116 * - proxyport: int, use another proxy port as specified in proxyhost
1117 * - proxyauth: string, proxy credentials in "user:pass" format
1118 * - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM
1119 * - httpauth: string, http credentials in "user:pass" format
1120 * - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM
1121 * - compress: bool, whether to allow gzip/deflate content encoding
1122 * (defaults to true)
1123 * - port: int, use another port as specified in the url
1124 * - referer: string, the referer to send
1125 * - useragent: string, the user agent to send
1126 * (defaults to PECL::HTTP/version (PHP/version)))
1127 * - headers: array, list of custom headers as associative array
1128 * like array("header" => "value")
1129 * - cookies: array, list of cookies as associative array
1130 * like array("cookie" => "value")
1131 * - cookiestore: string, path to a file where cookies are/will be stored
1132 * - resume: int, byte offset to start the download from;
1133 * if the server supports ranges
1134 * - maxfilesize: int, maximum file size that should be downloaded;
1135 * has no effect, if the size of the requested entity is not known
1136 * - lastmodified: int, timestamp for If-(Un)Modified-Since header
1137 * - timeout: int, seconds the request may take
1138 * - connecttimeout: int, seconds the connect may take
1139 * - onprogress: mixed, progress callback
1142 * The optional third parameter will be filled with some additional information
1143 * in form af an associative array, if supplied, like the following example:
1147 * 'effective_url' => 'http://localhost',
1148 * 'response_code' => 403,
1149 * 'total_time' => 0.017,
1150 * 'namelookup_time' => 0.013,
1151 * 'connect_time' => 0.014,
1152 * 'pretransfer_time' => 0.014,
1153 * 'size_upload' => 0,
1154 * 'size_download' => 202,
1155 * 'speed_download' => 11882,
1156 * 'speed_upload' => 0,
1157 * 'header_size' => 145,
1158 * 'request_size' => 62,
1159 * 'ssl_verifyresult' => 0,
1161 * 'content_length_download' => 202,
1162 * 'content_length_upload' => 0,
1163 * 'starttransfer_time' => 0.017,
1164 * 'content_type' => 'text/html; charset=iso-8859-1',
1165 * 'redirect_time' => 0,
1166 * 'redirect_count' => 0,
1167 * 'http_connectcode' => 0,
1168 * 'httpauth_avail' => 0,
1169 * 'proxyauth_avail' => 0,
1174 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1176 PHP_FUNCTION(http_get
)
1178 zval
*options
= NULL
, *info
= NULL
;
1181 http_request request
;
1183 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1194 http_request_init_ex(&request
, NULL
, HTTP_GET
, URL
);
1195 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1196 http_request_exec(&request
);
1198 http_request_info(&request
, Z_ARRVAL_P(info
));
1200 RETVAL_RESPONSE_OR_BODY(request
);
1202 http_request_dtor(&request
);
1206 /* {{{ proto string http_head(string url[, array options[, array &info]])
1208 * Performs an HTTP HEAD request on the supplied url.
1210 * See http_get() for a full list of available parameters and options.
1212 * Returns the HTTP response as string on success, or FALSE on failure.
1214 PHP_FUNCTION(http_head
)
1216 zval
*options
= NULL
, *info
= NULL
;
1219 http_request request
;
1221 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1232 http_request_init_ex(&request
, NULL
, HTTP_HEAD
, URL
);
1233 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1234 http_request_exec(&request
);
1236 http_request_info(&request
, Z_ARRVAL_P(info
));
1238 RETVAL_RESPONSE_OR_BODY(request
);
1240 http_request_dtor(&request
);
1244 /* {{{ proto string http_post_data(string url, string data[, array options[, array &info]])
1246 * Performs an HTTP POST requeston the supplied url.
1248 * Expects a string as second parameter containing the pre-encoded post data.
1249 * See http_get() for a full list of available parameters and options.
1251 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1253 PHP_FUNCTION(http_post_data
)
1255 zval
*options
= NULL
, *info
= NULL
;
1256 char *URL
, *postdata
;
1257 int postdata_len
, URL_len
;
1258 http_request_body body
;
1259 http_request request
;
1261 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &postdata
, &postdata_len
, &options
, &info
) != SUCCESS
) {
1272 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1273 request
.body
= http_request_body_init_ex(&body
, HTTP_REQUEST_BODY_CSTRING
, postdata
, postdata_len
, 0);
1274 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1275 http_request_exec(&request
);
1277 http_request_info(&request
, Z_ARRVAL_P(info
));
1279 RETVAL_RESPONSE_OR_BODY(request
);
1281 http_request_dtor(&request
);
1285 /* {{{ proto string http_post_fields(string url, array data[, array files[, array options[, array &info]]])
1287 * Performs an HTTP POST request on the supplied url.
1289 * Expecrs an associative array as second parameter, which will be
1290 * www-form-urlencoded. See http_get() for a full list of available options.
1292 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1294 PHP_FUNCTION(http_post_fields
)
1296 zval
*options
= NULL
, *info
= NULL
, *fields
, *files
= NULL
;
1299 http_request_body body
;
1300 http_request request
;
1302 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sa|aa/!z", &URL
, &URL_len
, &fields
, &files
, &options
, &info
) != SUCCESS
) {
1306 if (!http_request_body_fill(&body
, Z_ARRVAL_P(fields
), files
? Z_ARRVAL_P(files
) : NULL
)) {
1317 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1318 request
.body
= &body
;
1319 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1320 http_request_exec(&request
);
1322 http_request_info(&request
, Z_ARRVAL_P(info
));
1324 RETVAL_RESPONSE_OR_BODY(request
);
1326 http_request_dtor(&request
);
1330 /* {{{ proto string http_put_file(string url, string file[, array options[, array &info]])
1332 * Performs an HTTP PUT request on the supplied url.
1334 * Expects the second parameter to be a string referncing the file to upload.
1335 * See http_get() for a full list of available options.
1337 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1339 PHP_FUNCTION(http_put_file
)
1343 zval
*options
= NULL
, *info
= NULL
;
1345 php_stream_statbuf ssb
;
1346 http_request_body body
;
1347 http_request request
;
1349 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &file
, &f_len
, &options
, &info
)) {
1353 if (!(stream
= php_stream_open_wrapper(file
, "rb", REPORT_ERRORS
|ENFORCE_SAFE_MODE
, NULL
))) {
1356 if (php_stream_stat(stream
, &ssb
)) {
1357 php_stream_close(stream
);
1368 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1370 body
.size
= ssb
.sb
.st_size
;
1372 http_request_init_ex(&request
, NULL
, HTTP_PUT
, URL
);
1373 request
.body
= &body
;
1374 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1375 http_request_exec(&request
);
1377 http_request_info(&request
, Z_ARRVAL_P(info
));
1379 RETVAL_RESPONSE_OR_BODY(request
);
1381 http_request_body_dtor(&body
);
1382 request
.body
= NULL
;
1383 http_request_dtor(&request
);
1387 /* {{{ proto string http_put_stream(string url, resource stream[, array options[, array &info]])
1389 * Performs an HTTP PUT request on the supplied url.
1391 * Expects the second parameter to be a resource referencing an already
1392 * opened stream, from which the data to upload should be read.
1393 * See http_get() for a full list of available options.
1395 * Returns the HTTP response(s) as string on success. or FALSE on failure.
1397 PHP_FUNCTION(http_put_stream
)
1399 zval
*resource
, *options
= NULL
, *info
= NULL
;
1403 php_stream_statbuf ssb
;
1404 http_request_body body
;
1405 http_request request
;
1407 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sr|a/!z", &URL
, &URL_len
, &resource
, &options
, &info
)) {
1411 php_stream_from_zval(stream
, &resource
);
1412 if (php_stream_stat(stream
, &ssb
)) {
1423 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1425 body
.size
= ssb
.sb
.st_size
;
1427 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1428 request
.body
= &body
;
1429 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1430 http_request_exec(&request
);
1432 http_request_info(&request
, Z_ARRVAL_P(info
));
1434 RETVAL_RESPONSE_OR_BODY(request
);
1436 request
.body
= NULL
;
1437 http_request_dtor(&request
);
1440 #endif /* HTTP_HAVE_CURL */
1443 /* {{{ proto int http_request_method_register(string method)
1445 * Register a custom request method.
1447 * Expects a string parameter containing the request method name to register.
1449 * Returns the ID of the request method on success, or FALSE on failure.
1451 PHP_FUNCTION(http_request_method_register
)
1457 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &method
, &method_len
)) {
1460 if ((existing
= http_request_method_exists(1, 0, method
))) {
1461 RETURN_LONG((long) existing
);
1464 RETVAL_LONG((long) http_request_method_register(method
, method_len
));
1468 /* {{{ proto bool http_request_method_unregister(mixed method)
1470 * Unregister a previously registered custom request method.
1472 * Expects either the request method name or ID.
1474 * Returns TRUE on success, or FALSE on failure.
1476 PHP_FUNCTION(http_request_method_unregister
)
1480 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1484 switch (Z_TYPE_P(method
))
1487 convert_to_string(method
);
1489 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1490 convert_to_long(method
);
1493 if (!(mn
= http_request_method_exists(1, 0, Z_STRVAL_P(method
)))) {
1497 ZVAL_LONG(method
, (long)mn
);
1500 RETURN_SUCCESS(http_request_method_unregister(Z_LVAL_P(method
)));
1507 /* {{{ proto int http_request_method_exists(mixed method)
1509 * Check if a request method is registered (or available by default).
1511 * Expects either the request method name or ID as parameter.
1513 * Returns TRUE if the request method is known, else FALSE.
1515 PHP_FUNCTION(http_request_method_exists
)
1520 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1524 switch (Z_TYPE_P(method
))
1527 convert_to_string(method
);
1529 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1530 convert_to_long(method
);
1532 RETURN_LONG((long) http_request_method_exists(1, 0, Z_STRVAL_P(method
)));
1535 RETURN_LONG((long) http_request_method_exists(0, (int) Z_LVAL_P(method
), NULL
));
1543 /* {{{ proto string http_request_method_name(int method)
1545 * Get the literal string representation of a standard or registered request method.
1547 * Expects the request method ID as parameter.
1549 * Returns the request method name as string on success, or FALSE on failure.
1551 PHP_FUNCTION(http_request_method_name
)
1556 if ((SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &method
)) || (method
< 0)) {
1560 RETURN_STRING(estrdup(http_request_method_name((int) method
)), 0);
1565 /* {{{ Sara Golemons http_build_query() */
1566 #ifndef ZEND_ENGINE_2
1568 /* {{{ proto string http_build_query(mixed formdata [, string prefix[, string arg_separator]])
1569 Generates a form-encoded query string from an associative array or object. */
1570 PHP_FUNCTION(http_build_query
)
1573 char *prefix
= NULL
, *arg_sep
= INI_STR("arg_separator.output");
1574 int prefix_len
= 0, arg_sep_len
= strlen(arg_sep
);
1577 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|ss", &formdata
, &prefix
, &prefix_len
, &arg_sep
, &arg_sep_len
) != SUCCESS
) {
1582 arg_sep
= HTTP_URL_ARGSEP
;
1583 arg_sep_len
= lenof(HTTP_URL_ARGSEP
);
1586 formstr
= phpstr_new();
1587 if (SUCCESS
!= http_urlencode_hash_recursive(HASH_OF(formdata
), formstr
, arg_sep
, arg_sep_len
, prefix
, prefix_len
)) {
1588 phpstr_free(&formstr
);
1592 if (!formstr
->used
) {
1593 phpstr_free(&formstr
);
1597 RETURN_PHPSTR_PTR(formstr
);
1600 #endif /* !ZEND_ENGINE_2 */
1604 #ifdef HTTP_HAVE_ZLIB
1606 /* {{{ proto string http_deflate(string data[, int flags = 0])
1608 * Compress data with gzip, zlib AKA deflate or raw deflate encoding.
1610 * Expects the first parameter to be a string containing the data that should
1613 * Returns the encoded string on success, or NULL on failure.
1615 PHP_FUNCTION(http_deflate
)
1623 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|l", &data
, &data_len
, &flags
)) {
1627 if (SUCCESS
== http_encoding_deflate(flags
, data
, data_len
, &encoded
, &encoded_len
)) {
1628 RETURN_STRINGL(encoded
, (int) encoded_len
, 0);
1634 /* {{{ proto string http_inflate(string data)
1636 * Uncompress data compressed with either gzip, deflate AKA zlib or raw
1639 * Expects a string as parameter containing the compressed data.
1641 * Returns the decoded string on success, or NULL on failure.
1643 PHP_FUNCTION(http_inflate
)
1650 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &data
, &data_len
)) {
1654 if (SUCCESS
== http_encoding_inflate(data
, data_len
, &decoded
, &decoded_len
)) {
1655 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
1661 /* {{{ proto string ob_deflatehandler(string data, int mode)
1663 * For use with ob_start(). The deflate output buffer handler can only be used once.
1664 * It conflicts with ob_gzhanlder and zlib.output_compression as well and should
1665 * not be used after ext/mbstrings mb_output_handler and ext/sessions URL-Rewriter (AKA
1666 * session.use_trans_sid).
1668 PHP_FUNCTION(ob_deflatehandler
)
1674 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1678 http_ob_deflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1679 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1683 /* {{{ proto string ob_inflatehandler(string data, int mode)
1685 * For use with ob_start(). Same restrictions as with ob_deflatehandler apply.
1687 PHP_FUNCTION(ob_inflatehandler
)
1693 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1697 http_ob_inflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1698 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1702 #endif /* HTTP_HAVE_ZLIB */
1705 /* {{{ proto int http_support([int feature = 0])
1707 * Check for feature that require external libraries.
1709 * Accpepts an optional in parameter specifying which feature to probe for.
1710 * If the parameter is 0 or omitted, the return value contains a bitmask of
1711 * all supported features that depend on external libraries.
1713 * Available features to probe for are:
1715 * <li> HTTP_SUPPORT: always set
1716 * <li> HTTP_SUPPORT_REQUESTS: whether ext/http was linked against libcurl,
1717 * and HTTP requests can be issued
1718 * <li> HTTP_SUPPORT_SSLREQUESTS: whether libcurl was linked against openssl,
1719 * and SSL requests can be issued
1720 * <li> HTTP_SUPPORT_ENCODINGS: whether ext/http was linked against zlib,
1721 * and compressed HTTP responses can be decoded
1722 * <li> HTTP_SUPPORT_MAGICMIME: whether ext/http was linked against libmagic,
1723 * and the HttpResponse::guessContentType() method is usable
1726 * Returns int, whether requested feature is supported, or a bitmask with
1727 * all supported features.
1729 PHP_FUNCTION(http_support
)
1735 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &feature
)) {
1736 RETVAL_LONG(http_support(feature
));
1741 PHP_FUNCTION(http_test
)
1750 * vim600: noet sw=4 ts=4 fdm=marker
1751 * vim<600: noet sw=4 ts=4