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-2005, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
19 #define HTTP_WANT_CURL
20 #define HTTP_WANT_ZLIB
25 #include "ext/standard/info.h"
26 #include "ext/standard/php_string.h"
27 #include "zend_operators.h"
29 #if defined(HAVE_PHP_SESSION) && !defined(COMPILE_DL_SESSION)
30 # include "ext/session/php_session.h"
33 #include "php_http_api.h"
34 #include "php_http_cache_api.h"
35 #include "php_http_date_api.h"
36 #include "php_http_encoding_api.h"
37 #include "php_http_headers_api.h"
38 #include "php_http_message_api.h"
39 #include "php_http_request_api.h"
40 #include "php_http_request_method_api.h"
41 #include "php_http_send_api.h"
42 #include "php_http_url_api.h"
44 /* {{{ proto string http_date([int timestamp])
46 * Compose a valid HTTP date regarding RFC 822/1123
47 * looking like: "Wed, 22 Dec 2004 11:34:47 GMT"
49 * Takes an optional unix timestamp as parameter.
51 * Returns the HTTP date as string.
53 PHP_FUNCTION(http_date
)
57 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &t
) != SUCCESS
) {
62 t
= (long) time(NULL
);
65 RETURN_STRING(http_date(t
), 0);
69 /* {{{ proto string http_build_url(mixed url[, mixed parts[, array &new_url]])
71 * Returns the new URL as string on success or FALSE on failure.
73 PHP_FUNCTION(http_build_url
)
77 zval
*z_old_url
= NULL
, *z_new_url
= NULL
, *z_composed_url
= NULL
;
78 php_url
*old_url
= NULL
, *new_url
= NULL
, *composed_url
= NULL
;
80 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/|z/z", &z_old_url
, &z_new_url
, &z_composed_url
) != SUCCESS
) {
85 if (Z_TYPE_P(z_new_url
) == IS_ARRAY
|| Z_TYPE_P(z_new_url
) == IS_OBJECT
) {
86 new_url
= array2url(HASH_OF(z_new_url
));
88 convert_to_string(z_new_url
);
89 if (!(new_url
= php_url_parse_ex(Z_STRVAL_P(z_new_url
), Z_STRLEN_P(z_new_url
)))) {
90 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_new_url
));
96 if (Z_TYPE_P(z_old_url
) == IS_ARRAY
|| Z_TYPE_P(z_old_url
) == IS_OBJECT
) {
97 old_url
= array2url(HASH_OF(z_old_url
));
99 convert_to_string(z_old_url
);
100 if (!(old_url
= php_url_parse_ex(Z_STRVAL_P(z_old_url
), Z_STRLEN_P(z_old_url
)))) {
102 php_url_free(new_url
);
104 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_old_url
));
109 if (z_composed_url
) {
110 http_build_url(old_url
, new_url
, &composed_url
, &url_str
, &url_len
);
112 zval_dtor(z_composed_url
);
113 array_init(z_composed_url
);
114 if (composed_url
->scheme
) {
115 add_assoc_string(z_composed_url
, "scheme", composed_url
->scheme
, 1);
117 if (composed_url
->user
) {
118 add_assoc_string(z_composed_url
, "user", composed_url
->user
, 1);
120 if (composed_url
->pass
) {
121 add_assoc_string(z_composed_url
, "pass", composed_url
->pass
, 1);
123 if (composed_url
->host
) {
124 add_assoc_string(z_composed_url
, "host", composed_url
->host
, 1);
126 if (composed_url
->port
) {
127 add_assoc_long(z_composed_url
, "port", composed_url
->port
);
129 if (composed_url
->path
) {
130 add_assoc_string(z_composed_url
, "path", composed_url
->path
, 1);
132 if (composed_url
->query
) {
133 add_assoc_string(z_composed_url
, "query", composed_url
->query
, 1);
135 if (composed_url
->fragment
) {
136 add_assoc_string(z_composed_url
, "fragment", composed_url
->fragment
, 1);
138 php_url_free(composed_url
);
140 http_build_url(old_url
, new_url
, NULL
, &url_str
, &url_len
);
144 php_url_free(new_url
);
146 php_url_free(old_url
);
148 RETURN_STRINGL(url_str
, url_len
, 0);
152 #define HTTP_DO_NEGOTIATE(type, supported, rs_array) \
155 if ((result = http_negotiate_ ##type(supported))) { \
160 if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
161 RETVAL_STRINGL(key, key_len-1, 0); \
167 zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \
170 zend_hash_destroy(result); \
171 FREE_HASHTABLE(result); \
176 zend_hash_internal_pointer_reset(Z_ARRVAL_P(supported)); \
177 if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(supported), (void **) &value)) { \
178 RETVAL_ZVAL(*value, 1, 0); \
187 FOREACH_VAL(pos, supported, value) { \
188 convert_to_string_ex(value); \
189 add_assoc_double(rs_array, Z_STRVAL_PP(value), 1.0); \
196 /* {{{ proto string http_negotiate_language(array supported[, array &result])
198 * This function negotiates the clients preferred language based on its
199 * Accept-Language HTTP header. The qualifier is recognized and languages
200 * without qualifier are rated highest. The qualifier will be decreased by
201 * 10% for partial matches (i.e. matching primary language).
203 * Expects an array as parameter cotaining the supported languages as values.
204 * If the optional second parameter is supplied, it will be filled with an
205 * array containing the negotiation results.
207 * Returns the negotiated language or the default language (i.e. first array entry)
223 * include './langs/'. http_negotiate_language($langs, $result) .'.php';
229 PHP_FUNCTION(http_negotiate_language
)
231 zval
*supported
, *rs_array
= NULL
;
233 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
239 array_init(rs_array
);
242 HTTP_DO_NEGOTIATE(language
, supported
, rs_array
);
246 /* {{{ proto string http_negotiate_charset(array supported[, array &result])
248 * This function negotiates the clients preferred charset based on its
249 * Accept-Charset HTTP header. The qualifier is recognized and charsets
250 * without qualifier are rated highest.
252 * Expects an array as parameter cotaining the supported charsets as values.
253 * If the optional second parameter is supplied, it will be filled with an
254 * array containing the negotiation results.
256 * Returns the negotiated charset or the default charset (i.e. first array entry)
263 * 'iso-8859-1', // default
269 * $pref = http_negotiate_charset($charsets, $result);
271 * if (strcmp($pref, 'iso-8859-1')) {
272 * iconv_set_encoding('internal_encoding', 'iso-8859-1');
273 * iconv_set_encoding('output_encoding', $pref);
274 * ob_start('ob_iconv_handler');
281 PHP_FUNCTION(http_negotiate_charset
)
283 zval
*supported
, *rs_array
= NULL
;
285 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
291 array_init(rs_array
);
294 HTTP_DO_NEGOTIATE(charset
, supported
, rs_array
);
298 /* {{{ proto string http_negotiate_ctype(array supported[, array &result])
300 * This function negotiates the clients preferred content type based on its
301 * Accept HTTP header. The qualifier is recognized and content types
302 * without qualifier are rated highest.
304 * Expects an array as parameter cotaining the supported content types as values.
305 * If the optional second parameter is supplied, it will be filled with an
306 * array containing the negotiation results.
308 * Returns the negotiated content type or the default content type
309 * (i.e. first array entry) if none match.
314 * $ctypes = array('application/xhtml+xml', 'text/html');
315 * http_send_content_type(http_negotiate_content_type($ctypes));
319 PHP_FUNCTION(http_negotiate_content_type
)
321 zval
*supported
, *rs_array
= NULL
;
323 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
)) {
329 array_init(rs_array
);
332 HTTP_DO_NEGOTIATE(content_type
, supported
, rs_array
);
336 /* {{{ proto bool http_send_status(int status)
338 * Send HTTP status code.
340 * Expects an HTTP status code as parameter.
342 * Returns TRUE on success or FALSE on failure.
344 PHP_FUNCTION(http_send_status
)
348 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &status
) != SUCCESS
) {
351 if (status
< 100 || status
> 510) {
352 http_error_ex(HE_WARNING
, HTTP_E_HEADER
, "Invalid HTTP status code (100-510): %d", status
);
356 RETURN_SUCCESS(http_send_status(status
));
360 /* {{{ proto bool http_send_last_modified([int timestamp])
362 * Send a "Last-Modified" header with a valid HTTP date.
364 * Accepts a unix timestamp, converts it to a valid HTTP date and
365 * sends it as "Last-Modified" HTTP header. If timestamp is
366 * omitted, the current time will be sent.
368 * Returns TRUE on success or FALSE on failure.
370 PHP_FUNCTION(http_send_last_modified
)
374 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &t
) != SUCCESS
) {
379 t
= (long) time(NULL
);
382 RETURN_SUCCESS(http_send_last_modified(t
));
386 /* {{{ proto bool http_send_content_type([string content_type = 'application/x-octetstream'])
388 * Send the Content-Type of the sent entity. This is particularly important
389 * if you use the http_send() API.
391 * Accepts an optional string parameter containing the desired content type
392 * (primary/secondary).
394 * Returns TRUE on success or FALSE on failure.
396 PHP_FUNCTION(http_send_content_type
)
398 char *ct
= "application/x-octetstream";
399 int ct_len
= lenof("application/x-octetstream");
401 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &ct
, &ct_len
) != SUCCESS
) {
405 RETURN_SUCCESS(http_send_content_type(ct
, ct_len
));
409 /* {{{ proto bool http_send_content_disposition(string filename[, bool inline = false])
411 * Send the Content-Disposition. The Content-Disposition header is very useful
412 * if the data actually sent came from a file or something similar, that should
413 * be "saved" by the client/user (i.e. by browsers "Save as..." popup window).
415 * Expects a string parameter specifying the file name the "Save as..." dialogue
416 * should display. Optionally accepts a bool parameter, which, if set to true
417 * and the user agent knows how to handle the content type, will probably not
418 * cause the popup window to be shown.
420 * Returns TRUE on success or FALSE on failure.
422 PHP_FUNCTION(http_send_content_disposition
)
426 zend_bool send_inline
= 0;
428 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &filename
, &f_len
, &send_inline
) != SUCCESS
) {
431 RETURN_SUCCESS(http_send_content_disposition(filename
, f_len
, send_inline
));
435 /* {{{ proto bool http_match_modified([int timestamp[, bool for_range = false]])
437 * Matches the given unix timestamp against the clients "If-Modified-Since"
438 * resp. "If-Unmodified-Since" HTTP headers.
440 * Accepts a unix timestamp which should be matched. Optionally accepts an
441 * additional bool parameter, which if set to true will check the header
442 * usually used to validate HTTP ranges. If timestamp is omitted, the
443 * current time will be used.
445 * Returns TRUE if timestamp represents an earlier date than the header,
448 PHP_FUNCTION(http_match_modified
)
451 zend_bool for_range
= 0;
453 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|lb", &t
, &for_range
) != SUCCESS
) {
457 // current time if not supplied (senseless though)
459 t
= (long) time(NULL
);
463 RETURN_BOOL(http_match_last_modified("HTTP_IF_UNMODIFIED_SINCE", t
));
465 RETURN_BOOL(http_match_last_modified("HTTP_IF_MODIFIED_SINCE", t
));
469 /* {{{ proto bool http_match_etag(string etag[, bool for_range = false])
471 * Matches the given ETag against the clients "If-Match" resp.
472 * "If-None-Match" HTTP headers.
474 * Expects a string parameter containing the ETag to compare. Optionally
475 * accepts a bool parameter, which, if set to true, will check the header
476 * usually used to validate HTTP ranges.
478 * Retuns TRUE if ETag matches or the header contained the asterisk ("*"),
481 PHP_FUNCTION(http_match_etag
)
485 zend_bool for_range
= 0;
487 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &etag
, &etag_len
, &for_range
) != SUCCESS
) {
492 RETURN_BOOL(http_match_etag("HTTP_IF_MATCH", etag
));
494 RETURN_BOOL(http_match_etag("HTTP_IF_NONE_MATCH", etag
));
498 /* {{{ proto bool http_cache_last_modified([int timestamp_or_expires]])
500 * Attempts to cache the sent entity by its last modification date.
502 * Accepts a unix timestamp as parameter which is handled as follows:
504 * If timestamp_or_expires is greater than 0, it is handled as timestamp
505 * and will be sent as date of last modification. If it is 0 or omitted,
506 * the current time will be sent as Last-Modified date. If it's negative,
507 * it is handled as expiration time in seconds, which means that if the
508 * requested last modification date is not between the calculated timespan,
509 * the Last-Modified header is updated and the actual body will be sent.
511 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
513 * A log entry will be written to the cache log if the INI entry
514 * http.cache_log is set and the cache attempt was successful.
516 PHP_FUNCTION(http_cache_last_modified
)
518 long last_modified
= 0, send_modified
= 0, t
;
521 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &last_modified
) != SUCCESS
) {
525 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
527 t
= (long) time(NULL
);
530 if (!last_modified
) {
531 /* does the client have? (att: caching "forever") */
532 if ((zlm
= http_get_server_var("HTTP_IF_MODIFIED_SINCE"))) {
533 last_modified
= send_modified
= http_parse_date(Z_STRVAL_P(zlm
));
534 /* send current time */
538 /* negative value is supposed to be expiration time */
539 } else if (last_modified
< 0) {
542 /* send supplied time explicitly */
544 send_modified
= last_modified
;
547 RETURN_SUCCESS(http_cache_last_modified(last_modified
, send_modified
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
551 /* {{{ proto bool http_cache_etag([string etag])
553 * Attempts to cache the sent entity by its ETag, either supplied or generated
554 * by the hash algorythm specified by the INI setting "http.etag_mode".
556 * If the clients "If-None-Match" header matches the supplied/calculated
557 * ETag, the body is considered cached on the clients side and
558 * a "304 Not Modified" status code is issued.
560 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
562 * A log entry is written to the cache log if the INI entry
563 * "http.cache_log" is set and the cache attempt was successful.
565 PHP_FUNCTION(http_cache_etag
)
570 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &etag
, &etag_len
) != SUCCESS
) {
574 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
576 RETURN_SUCCESS(http_cache_etag(etag
, etag_len
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
580 /* {{{ proto string ob_etaghandler(string data, int mode)
582 * For use with ob_start(). Output buffer handler generating an ETag with
583 * the hash algorythm specified with the INI setting "http.etag_mode".
585 PHP_FUNCTION(ob_etaghandler
)
591 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
595 Z_TYPE_P(return_value
) = IS_STRING
;
596 http_ob_etaghandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
600 /* {{{ proto void http_throttle(double sec[, int bytes = 40960])
602 * Sets the throttle delay and send buffer size for use with http_send() API.
603 * Provides a basic throttling mechanism, which will yield the current process
604 * resp. thread until the entity has been completely sent, though.
606 * Expects a double parameter specifying the seconds too sleep() after
607 * each chunk sent. Additionally accepts an optional int parameter
608 * representing the chunk size in bytes.
614 * # http_throttle(1, 20000);
615 * # http_throttle(0.5, 10000);
616 * # http_throttle(0.1, 2000);
617 * http_send_file('document.pdf');
621 PHP_FUNCTION(http_throttle
)
623 long chunk_size
= HTTP_SENDBUF_SIZE
;
626 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "d|l", &interval
, &chunk_size
)) {
630 HTTP_G(send
).throttle_delay
= interval
;
631 HTTP_G(send
).buffer_size
= chunk_size
;
635 /* {{{ proto void http_redirect([string url[, array params[, bool session = false[, int status = 302]]]])
637 * Redirect to the given url.
639 * The supplied url will be expanded with http_build_uri(), the params array will
640 * be treated with http_build_query() and the session identification will be appended
641 * if session is true.
643 * The HTTP response code will be set according to status.
644 * You can use one of the following constants for convenience:
645 * - HTTP_REDIRECT 302 Found
646 * - HTTP_REDIRECT_PERM 301 Moved Permanently
647 * - HTTP_REDIRECT_POST 303 See Other
648 * - HTTP_REDIRECT_TEMP 307 Temporary Redirect
650 * Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
651 * for which redirect response code to use in which situation.
653 * To be RFC compliant, "Redirecting to <a>URI</a>." will be displayed,
654 * if the client doesn't redirect immediatly, and the request method was
655 * another one than HEAD.
657 * Returns FALSE on failure, or *exits* on success.
659 * A log entry will be written to the redirect log, if the INI entry
660 * "http.redirect_log" is set and the redirect attempt was successful.
662 PHP_FUNCTION(http_redirect
)
665 size_t query_len
= 0;
666 zend_bool session
= 0, free_params
= 0;
669 char *query
= NULL
, *url
= NULL
, *URI
, *LOC
, *RED
= NULL
;
671 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|sa!/bl", &url
, &url_len
, ¶ms
, &session
, &status
) != SUCCESS
) {
675 /* append session info */
679 MAKE_STD_ZVAL(params
);
682 #ifdef HAVE_PHP_SESSION
683 # ifdef COMPILE_DL_SESSION
684 if (SUCCESS
== zend_get_module_started("session")) {
685 zval nm_retval
, id_retval
, func
;
688 INIT_PZVAL(&nm_retval
);
689 INIT_PZVAL(&id_retval
);
690 ZVAL_NULL(&nm_retval
);
691 ZVAL_NULL(&id_retval
);
693 ZVAL_STRINGL(&func
, "session_id", lenof("session_id"), 0);
694 call_user_function(EG(function_table
), NULL
, &func
, &id_retval
, 0, NULL TSRMLS_CC
);
695 ZVAL_STRINGL(&func
, "session_name", lenof("session_name"), 0);
696 call_user_function(EG(function_table
), NULL
, &func
, &nm_retval
, 0, NULL TSRMLS_CC
);
698 if ( Z_TYPE(nm_retval
) == IS_STRING
&& Z_STRLEN(nm_retval
) &&
699 Z_TYPE(id_retval
) == IS_STRING
&& Z_STRLEN(id_retval
)) {
700 if (add_assoc_stringl_ex(params
, Z_STRVAL(nm_retval
), Z_STRLEN(nm_retval
)+1,
701 Z_STRVAL(id_retval
), Z_STRLEN(id_retval
), 0) != SUCCESS
) {
702 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Could not append session information");
707 if (PS(session_status
) == php_session_active
) {
708 if (add_assoc_string(params
, PS(session_name
), PS(id
), 1) != SUCCESS
) {
709 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Could not append session information");
716 /* treat params array with http_build_query() */
718 if (SUCCESS
!= http_urlencode_hash_ex(Z_ARRVAL_P(params
), 0, NULL
, 0, &query
, &query_len
)) {
730 URI
= http_absolute_url(url
);
733 spprintf(&LOC
, 0, "Location: %s?%s", URI
, query
);
734 if (SG(request_info
).request_method
&& strcmp(SG(request_info
).request_method
, "HEAD")) {
735 spprintf(&RED
, 0, "Redirecting to <a href=\"%s?%s\">%s?%s</a>.\n", URI
, query
, URI
, query
);
738 spprintf(&LOC
, 0, "Location: %s", URI
);
739 if (SG(request_info
).request_method
&& strcmp(SG(request_info
).request_method
, "HEAD")) {
740 spprintf(&RED
, 0, "Redirecting to <a href=\"%s\">%s</a>.\n", URI
, URI
);
753 RETURN_SUCCESS(http_exit_ex(status
, LOC
, RED
, 1));
757 /* {{{ proto bool http_send_data(string data)
759 * Sends raw data with support for (multiple) range requests.
761 * Retursn TRUE on success, or FALSE on failure.
763 PHP_FUNCTION(http_send_data
)
767 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z", &zdata
) != SUCCESS
) {
771 convert_to_string_ex(&zdata
);
772 RETURN_SUCCESS(http_send_data(Z_STRVAL_P(zdata
), Z_STRLEN_P(zdata
)));
776 /* {{{ proto bool http_send_file(string file)
778 * Sends a file with support for (multiple) range requests.
780 * Expects a string parameter referencing the file to send.
782 * Returns TRUE on success, or FALSE on failure.
784 PHP_FUNCTION(http_send_file
)
789 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &file
, &flen
) != SUCCESS
) {
796 RETURN_SUCCESS(http_send_file(file
));
800 /* {{{ proto bool http_send_stream(resource stream)
802 * Sends an already opened stream with support for (multiple) range requests.
804 * Expects a resource parameter referncing the stream to read from.
806 * Returns TRUE on success, or FALSE on failure.
808 PHP_FUNCTION(http_send_stream
)
813 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &zstream
) != SUCCESS
) {
817 php_stream_from_zval(file
, &zstream
);
818 RETURN_SUCCESS(http_send_stream(file
));
822 /* {{{ proto string http_chunked_decode(string encoded)
824 * Decodes a string that was HTTP-chunked encoded.
826 * Expects a chunked encoded string as parameter.
828 * Returns the decoded string on success or FALSE on failure.
830 PHP_FUNCTION(http_chunked_decode
)
832 char *encoded
= NULL
, *decoded
= NULL
;
833 size_t decoded_len
= 0;
836 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &encoded
, &encoded_len
) != SUCCESS
) {
840 if (NULL
!= http_encoding_dechunk(encoded
, encoded_len
, &decoded
, &decoded_len
)) {
841 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
848 /* {{{ proto object http_parse_message(string message)
850 * Parses (a) http_message(s) into a simple recursive object structure.
852 * Expects a string parameter containing a single HTTP message or
853 * several consecutive HTTP messages.
855 * Returns an hierachical object structure of the parsed messages.
860 * print_r(http_parse_message(http_get(URL, array('redirect' => 3)));
865 * [httpVersion] => 1.1
866 * [responseCode] => 200
869 * [Content-Length] => 3
873 * [parentMessage] => stdClass object
876 * [httpVersion] => 1.1
877 * [responseCode] => 302
880 * [Content-Length] => 0
884 * [parentMessage] => ...
890 PHP_FUNCTION(http_parse_message
)
894 http_message
*msg
= NULL
;
896 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &message
, &message_len
)) {
900 if ((msg
= http_message_parse(message
, message_len
))) {
901 object_init(return_value
);
902 http_message_tostruct_recursive(msg
, return_value
);
903 http_message_free(&msg
);
910 /* {{{ proto array http_parse_headers(string header)
912 * Parses HTTP headers into an associative array.
914 * Expects a string parameter containing HTTP headers.
916 * Returns an array on success, or FALSE on failure.
921 * $headers = "content-type: text/html; charset=UTF-8\r\n".
922 * "Server: Funky/1.0\r\n".
923 * "Set-Cookie: foo=bar\r\n".
924 * "Set-Cookie: baz=quux\r\n".
925 * "Folded: works\r\n\ttoo\r\n";
926 * print_r(http_parse_headers($headers));
930 * [Content-Type] => text/html; chatset=UTF-8
931 * [Server] => Funky/1.0
932 * [Set-Cookie] => Array
943 PHP_FUNCTION(http_parse_headers
)
948 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &header
, &header_len
)) {
952 array_init(return_value
);
953 if (SUCCESS
!= http_parse_headers(header
, return_value
)) {
954 zval_dtor(return_value
);
960 /* {{{ proto object http_parse_cookie(string cookie)
962 * Parses HTTP cookies like sent in a response into a struct.
964 * Expects a string as parameter containing the value of a Set-Cookie response header.
966 * Returns an stdClass object with the cookie params as properties on success or FALSE on failure.
971 * print_r(http_parse_cookie("foo=bar; path=/"));
982 PHP_FUNCTION(http_parse_cookie
)
987 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &cookie
, &cookie_len
)) {
991 object_init(return_value
);
992 if (SUCCESS
!= http_parse_cookie(cookie
, HASH_OF(return_value
))) {
993 zval_dtor(return_value
);
998 /* {{{ proto array http_get_request_headers(void)
1000 * Get a list of incoming HTTP headers.
1002 * Returns an associative array of incoming request headers.
1004 PHP_FUNCTION(http_get_request_headers
)
1008 array_init(return_value
);
1009 http_get_request_headers(return_value
);
1013 /* {{{ proto string http_get_request_body(void)
1015 * Get the raw request body (e.g. POST or PUT data).
1017 * Returns NULL when using the CLI SAPI.
1019 PHP_FUNCTION(http_get_request_body
)
1026 if (SUCCESS
== http_get_request_body(&body
, &length
)) {
1027 RETURN_STRINGL(body
, (int) length
, 0);
1034 /* {{{ proto bool http_match_request_header(string header, string value[, bool match_case = false])
1036 * Match an incoming HTTP header.
1038 * Expects two string parameters representing the header name (case-insensitive)
1039 * and the header value that should be compared. The case sensitivity of the
1040 * header value depends on the additional optional bool parameter accepted.
1042 * Returns TRUE if header value matches, else FALSE.
1044 PHP_FUNCTION(http_match_request_header
)
1046 char *header
, *value
;
1047 int header_len
, value_len
;
1048 zend_bool match_case
= 0;
1050 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|b", &header
, &header_len
, &value
, &value_len
, &match_case
)) {
1054 RETURN_BOOL(http_match_request_header_ex(header
, value
, match_case
));
1059 #ifdef HTTP_HAVE_CURL
1061 #define RETVAL_RESPONSE_OR_BODY(request) \
1065 /* check if only the body should be returned */ \
1066 if (options && (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), "bodyonly", sizeof("bodyonly"), (void **) &bodyonly)) && zval_is_true(*bodyonly)) { \
1067 http_message *msg = http_message_parse(PHPSTR_VAL(&request.conv.response), PHPSTR_LEN(&request.conv.response)); \
1070 RETVAL_STRINGL(PHPSTR_VAL(&msg->body), PHPSTR_LEN(&msg->body), 1); \
1071 http_message_free(&msg); \
1074 RETVAL_STRINGL(request.conv.response.data, request.conv.response.used, 1); \
1078 /* {{{ proto string http_get(string url[, array options[, array &info]])
1080 * Performs an HTTP GET request on the supplied url.
1082 * The second parameter, if set, is expected to be an associative
1083 * array where the following keys will be recognized:
1085 * - redirect: int, whether and how many redirects to follow
1086 * - unrestrictedauth: bool, whether to continue sending credentials on
1087 * redirects to a different host
1088 * - proxyhost: string, proxy host in "host[:port]" format
1089 * - proxyport: int, use another proxy port as specified in proxyhost
1090 * - proxyauth: string, proxy credentials in "user:pass" format
1091 * - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM
1092 * - httpauth: string, http credentials in "user:pass" format
1093 * - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM
1094 * - compress: bool, whether to allow gzip/deflate content encoding
1095 * (defaults to true)
1096 * - port: int, use another port as specified in the url
1097 * - referer: string, the referer to send
1098 * - useragent: string, the user agent to send
1099 * (defaults to PECL::HTTP/version (PHP/version)))
1100 * - headers: array, list of custom headers as associative array
1101 * like array("header" => "value")
1102 * - cookies: array, list of cookies as associative array
1103 * like array("cookie" => "value")
1104 * - cookiestore: string, path to a file where cookies are/will be stored
1105 * - resume: int, byte offset to start the download from;
1106 * if the server supports ranges
1107 * - maxfilesize: int, maximum file size that should be downloaded;
1108 * has no effect, if the size of the requested entity is not known
1109 * - lastmodified: int, timestamp for If-(Un)Modified-Since header
1110 * - timeout: int, seconds the request may take
1111 * - connecttimeout: int, seconds the connect may take
1112 * - onprogress: mixed, progress callback
1115 * The optional third parameter will be filled with some additional information
1116 * in form af an associative array, if supplied, like the following example:
1120 * 'effective_url' => 'http://localhost',
1121 * 'response_code' => 403,
1122 * 'total_time' => 0.017,
1123 * 'namelookup_time' => 0.013,
1124 * 'connect_time' => 0.014,
1125 * 'pretransfer_time' => 0.014,
1126 * 'size_upload' => 0,
1127 * 'size_download' => 202,
1128 * 'speed_download' => 11882,
1129 * 'speed_upload' => 0,
1130 * 'header_size' => 145,
1131 * 'request_size' => 62,
1132 * 'ssl_verifyresult' => 0,
1134 * 'content_length_download' => 202,
1135 * 'content_length_upload' => 0,
1136 * 'starttransfer_time' => 0.017,
1137 * 'content_type' => 'text/html; charset=iso-8859-1',
1138 * 'redirect_time' => 0,
1139 * 'redirect_count' => 0,
1140 * 'http_connectcode' => 0,
1141 * 'httpauth_avail' => 0,
1142 * 'proxyauth_avail' => 0,
1147 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1149 PHP_FUNCTION(http_get
)
1151 zval
*options
= NULL
, *info
= NULL
;
1154 http_request request
;
1156 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1167 http_request_init_ex(&request
, NULL
, HTTP_GET
, URL
);
1168 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1169 http_request_exec(&request
);
1171 http_request_info(&request
, Z_ARRVAL_P(info
));
1173 RETVAL_RESPONSE_OR_BODY(request
);
1175 http_request_dtor(&request
);
1179 /* {{{ proto string http_head(string url[, array options[, array &info]])
1181 * Performs an HTTP HEAD request on the supplied url.
1183 * See http_get() for a full list of available parameters and options.
1185 * Returns the HTTP response as string on success, or FALSE on failure.
1187 PHP_FUNCTION(http_head
)
1189 zval
*options
= NULL
, *info
= NULL
;
1192 http_request request
;
1194 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1205 http_request_init_ex(&request
, NULL
, HTTP_HEAD
, URL
);
1206 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1207 http_request_exec(&request
);
1209 http_request_info(&request
, Z_ARRVAL_P(info
));
1211 RETVAL_RESPONSE_OR_BODY(request
);
1213 http_request_dtor(&request
);
1217 /* {{{ proto string http_post_data(string url, string data[, array options[, array &info]])
1219 * Performs an HTTP POST requeston the supplied url.
1221 * Expects a string as second parameter containing the pre-encoded post data.
1222 * See http_get() for a full list of available parameters and options.
1224 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1226 PHP_FUNCTION(http_post_data
)
1228 zval
*options
= NULL
, *info
= NULL
;
1229 char *URL
, *postdata
;
1230 int postdata_len
, URL_len
;
1231 http_request_body body
;
1232 http_request request
;
1234 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &postdata
, &postdata_len
, &options
, &info
) != SUCCESS
) {
1245 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1246 request
.body
= http_request_body_init_ex(&body
, HTTP_REQUEST_BODY_CSTRING
, postdata
, postdata_len
, 0);
1247 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1248 http_request_exec(&request
);
1250 http_request_info(&request
, Z_ARRVAL_P(info
));
1252 RETVAL_RESPONSE_OR_BODY(request
);
1254 http_request_dtor(&request
);
1258 /* {{{ proto string http_post_fields(string url, array data[, array files[, array options[, array &info]]])
1260 * Performs an HTTP POST request on the supplied url.
1262 * Expecrs an associative array as second parameter, which will be
1263 * www-form-urlencoded. See http_get() for a full list of available options.
1265 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1267 PHP_FUNCTION(http_post_fields
)
1269 zval
*options
= NULL
, *info
= NULL
, *fields
, *files
= NULL
;
1272 http_request_body body
;
1273 http_request request
;
1275 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sa|aa/!z", &URL
, &URL_len
, &fields
, &files
, &options
, &info
) != SUCCESS
) {
1279 if (!http_request_body_fill(&body
, Z_ARRVAL_P(fields
), files
? Z_ARRVAL_P(files
) : NULL
)) {
1290 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1291 request
.body
= &body
;
1292 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1293 http_request_exec(&request
);
1295 http_request_info(&request
, Z_ARRVAL_P(info
));
1297 RETVAL_RESPONSE_OR_BODY(request
);
1299 http_request_dtor(&request
);
1303 /* {{{ proto string http_put_file(string url, string file[, array options[, array &info]])
1305 * Performs an HTTP PUT request on the supplied url.
1307 * Expects the second parameter to be a string referncing the file to upload.
1308 * See http_get() for a full list of available options.
1310 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1312 PHP_FUNCTION(http_put_file
)
1316 zval
*options
= NULL
, *info
= NULL
;
1318 php_stream_statbuf ssb
;
1319 http_request_body body
;
1320 http_request request
;
1322 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &file
, &f_len
, &options
, &info
)) {
1326 if (!(stream
= php_stream_open_wrapper(file
, "rb", REPORT_ERRORS
|ENFORCE_SAFE_MODE
, NULL
))) {
1329 if (php_stream_stat(stream
, &ssb
)) {
1330 php_stream_close(stream
);
1341 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1343 body
.size
= ssb
.sb
.st_size
;
1345 http_request_init_ex(&request
, NULL
, HTTP_PUT
, URL
);
1346 request
.body
= &body
;
1347 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1348 http_request_exec(&request
);
1350 http_request_info(&request
, Z_ARRVAL_P(info
));
1352 RETVAL_RESPONSE_OR_BODY(request
);
1354 http_request_body_dtor(&body
);
1355 request
.body
= NULL
;
1356 http_request_dtor(&request
);
1360 /* {{{ proto string http_put_stream(string url, resource stream[, array options[, array &info]])
1362 * Performs an HTTP PUT request on the supplied url.
1364 * Expects the second parameter to be a resource referencing an already
1365 * opened stream, from which the data to upload should be read.
1366 * See http_get() for a full list of available options.
1368 * Returns the HTTP response(s) as string on success. or FALSE on failure.
1370 PHP_FUNCTION(http_put_stream
)
1372 zval
*resource
, *options
= NULL
, *info
= NULL
;
1376 php_stream_statbuf ssb
;
1377 http_request_body body
;
1378 http_request request
;
1380 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sr|a/!z", &URL
, &URL_len
, &resource
, &options
, &info
)) {
1384 php_stream_from_zval(stream
, &resource
);
1385 if (php_stream_stat(stream
, &ssb
)) {
1396 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1398 body
.size
= ssb
.sb
.st_size
;
1400 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1401 request
.body
= &body
;
1402 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1403 http_request_exec(&request
);
1405 http_request_info(&request
, Z_ARRVAL_P(info
));
1407 RETVAL_RESPONSE_OR_BODY(request
);
1409 request
.body
= NULL
;
1410 http_request_dtor(&request
);
1413 #endif /* HTTP_HAVE_CURL */
1416 /* {{{ proto int http_request_method_register(string method)
1418 * Register a custom request method.
1420 * Expects a string parameter containing the request method name to register.
1422 * Returns the ID of the request method on success, or FALSE on failure.
1424 PHP_FUNCTION(http_request_method_register
)
1430 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &method
, &method_len
)) {
1433 if ((existing
= http_request_method_exists(1, 0, method
))) {
1434 RETURN_LONG((long) existing
);
1437 RETVAL_LONG((long) http_request_method_register(method
, method_len
));
1441 /* {{{ proto bool http_request_method_unregister(mixed method)
1443 * Unregister a previously registered custom request method.
1445 * Expects either the request method name or ID.
1447 * Returns TRUE on success, or FALSE on failure.
1449 PHP_FUNCTION(http_request_method_unregister
)
1453 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1457 switch (Z_TYPE_P(method
))
1460 convert_to_string(method
);
1462 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1463 convert_to_long(method
);
1466 if (!(mn
= http_request_method_exists(1, 0, Z_STRVAL_P(method
)))) {
1470 ZVAL_LONG(method
, (long)mn
);
1473 RETURN_SUCCESS(http_request_method_unregister(Z_LVAL_P(method
)));
1480 /* {{{ proto int http_request_method_exists(mixed method)
1482 * Check if a request method is registered (or available by default).
1484 * Expects either the request method name or ID as parameter.
1486 * Returns TRUE if the request method is known, else FALSE.
1488 PHP_FUNCTION(http_request_method_exists
)
1493 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1497 switch (Z_TYPE_P(method
))
1500 convert_to_string(method
);
1502 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1503 convert_to_long(method
);
1505 RETURN_LONG((long) http_request_method_exists(1, 0, Z_STRVAL_P(method
)));
1508 RETURN_LONG((long) http_request_method_exists(0, Z_LVAL_P(method
), NULL
));
1516 /* {{{ proto string http_request_method_name(int method)
1518 * Get the literal string representation of a standard or registered request method.
1520 * Expects the request method ID as parameter.
1522 * Returns the request method name as string on success, or FALSE on failure.
1524 PHP_FUNCTION(http_request_method_name
)
1529 if ((SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &method
)) || (method
< 0)) {
1533 RETURN_STRING(estrdup(http_request_method_name((ulong
) method
)), 0);
1538 /* {{{ Sara Golemons http_build_query() */
1539 #ifndef ZEND_ENGINE_2
1541 /* {{{ proto string http_build_query(mixed formdata [, string prefix[, string arg_separator]])
1542 Generates a form-encoded query string from an associative array or object. */
1543 PHP_FUNCTION(http_build_query
)
1546 char *prefix
= NULL
, *arg_sep
= INI_STR("arg_separator.output");
1547 int prefix_len
= 0, arg_sep_len
= strlen(arg_sep
);
1550 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|ss", &formdata
, &prefix
, &prefix_len
, &arg_sep
, &arg_sep_len
) != SUCCESS
) {
1555 arg_sep
= HTTP_URL_ARGSEP
;
1556 arg_sep_len
= lenof(HTTP_URL_ARGSEP
);
1559 formstr
= phpstr_new();
1560 if (SUCCESS
!= http_urlencode_hash_recursive(HASH_OF(formdata
), formstr
, arg_sep
, arg_sep_len
, prefix
, prefix_len
)) {
1561 phpstr_free(&formstr
);
1565 if (!formstr
->used
) {
1566 phpstr_free(&formstr
);
1570 RETURN_PHPSTR_PTR(formstr
);
1573 #endif /* !ZEND_ENGINE_2 */
1577 #ifdef HTTP_HAVE_ZLIB
1579 /* {{{ proto string http_deflate(string data[, int flags = 0])
1581 * Compress data with gzip, zlib AKA deflate or raw deflate encoding.
1583 * Expects the first parameter to be a string containing the data that should
1586 * Returns the encoded string on success, or NULL on failure.
1588 PHP_FUNCTION(http_deflate
)
1596 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|l", &data
, &data_len
, &flags
)) {
1600 if (SUCCESS
== http_encoding_deflate(flags
, data
, data_len
, &encoded
, &encoded_len
)) {
1601 RETURN_STRINGL(encoded
, (int) encoded_len
, 0);
1607 /* {{{ proto string http_inflate(string data)
1609 * Uncompress data compressed with either gzip, deflate AKA zlib or raw
1612 * Expects a string as parameter containing the compressed data.
1614 * Returns the decoded string on success, or NULL on failure.
1616 PHP_FUNCTION(http_inflate
)
1623 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &data
, &data_len
)) {
1627 if (SUCCESS
== http_encoding_inflate(data
, data_len
, &decoded
, &decoded_len
)) {
1628 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
1634 /* {{{ proto string ob_deflatehandler(string data, int mode)
1636 * For use with ob_start(). The deflate output buffer handler can only be used once.
1637 * It conflicts with ob_gzhanlder and zlib.output_compression as well and should
1638 * not be used after ext/mbstrings mb_output_handler and ext/sessions URL-Rewriter (AKA
1639 * session.use_trans_sid).
1641 PHP_FUNCTION(ob_deflatehandler
)
1647 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1651 http_ob_deflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1652 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1656 /* {{{ proto string ob_inflatehandler(string data, int mode)
1658 * For use with ob_start(). Same restrictions as with ob_deflatehandler apply.
1660 PHP_FUNCTION(ob_inflatehandler
)
1666 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1670 http_ob_inflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1671 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1675 #endif /* HTTP_HAVE_ZLIB */
1678 /* {{{ proto int http_support([int feature = 0])
1680 * Check for feature that require external libraries.
1682 * Accpepts an optional in parameter specifying which feature to probe for.
1683 * If the parameter is 0 or omitted, the return value contains a bitmask of
1684 * all supported features that depend on external libraries.
1686 * Available features to probe for are:
1688 * <li> HTTP_SUPPORT: always set
1689 * <li> HTTP_SUPPORT_REQUESTS: whether ext/http was linked against libcurl,
1690 * and HTTP requests can be issued
1691 * <li> HTTP_SUPPORT_SSLREQUESTS: whether libcurl was linked against openssl,
1692 * and SSL requests can be issued
1693 * <li> HTTP_SUPPORT_ENCODINGS: whether ext/http was linked against zlib,
1694 * and compressed HTTP responses can be decoded
1695 * <li> HTTP_SUPPORT_MAGICMIME: whether ext/http was linked against libmagic,
1696 * and the HttpResponse::guessContentType() method is usable
1699 * Returns int, whether requested feature is supported, or a bitmask with
1700 * all supported features.
1702 PHP_FUNCTION(http_support
)
1708 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &feature
)) {
1709 RETVAL_LONG(http_support(feature
));
1714 PHP_FUNCTION(http_test
)
1723 * vim600: noet sw=4 ts=4 fdm=marker
1724 * vim<600: noet sw=4 ts=4