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 * Accepts 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[, int flags = HTTP_URL_REPLACE[, array &new_url]]])
66 * Returns the new URL as string on success or FALSE on failure.
68 PHP_FUNCTION(http_build_url
)
72 long flags
= HTTP_URL_REPLACE
;
73 zval
*z_old_url
= NULL
, *z_new_url
= NULL
, *z_composed_url
= NULL
;
74 php_url
*old_url
= NULL
, *new_url
= NULL
, *composed_url
= NULL
;
76 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/|z/lz", &z_old_url
, &z_new_url
, &flags
, &z_composed_url
) != SUCCESS
) {
81 if (Z_TYPE_P(z_new_url
) == IS_ARRAY
|| Z_TYPE_P(z_new_url
) == IS_OBJECT
) {
82 new_url
= array2url(HASH_OF(z_new_url
));
84 convert_to_string(z_new_url
);
85 if (!(new_url
= php_url_parse_ex(Z_STRVAL_P(z_new_url
), Z_STRLEN_P(z_new_url
)))) {
86 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_new_url
));
92 if (Z_TYPE_P(z_old_url
) == IS_ARRAY
|| Z_TYPE_P(z_old_url
) == IS_OBJECT
) {
93 old_url
= array2url(HASH_OF(z_old_url
));
95 convert_to_string(z_old_url
);
96 if (!(old_url
= php_url_parse_ex(Z_STRVAL_P(z_old_url
), Z_STRLEN_P(z_old_url
)))) {
98 php_url_free(new_url
);
100 http_error_ex(HE_WARNING
, HTTP_E_URL
, "Could not parse URL (%s)", Z_STRVAL_P(z_old_url
));
105 if (z_composed_url
) {
106 http_build_url(flags
, old_url
, new_url
, &composed_url
, &url_str
, &url_len
);
108 zval_dtor(z_composed_url
);
109 array_init(z_composed_url
);
110 if (composed_url
->scheme
) {
111 add_assoc_string(z_composed_url
, "scheme", composed_url
->scheme
, 1);
113 if (composed_url
->user
) {
114 add_assoc_string(z_composed_url
, "user", composed_url
->user
, 1);
116 if (composed_url
->pass
) {
117 add_assoc_string(z_composed_url
, "pass", composed_url
->pass
, 1);
119 if (composed_url
->host
) {
120 add_assoc_string(z_composed_url
, "host", composed_url
->host
, 1);
122 if (composed_url
->port
) {
123 add_assoc_long(z_composed_url
, "port", composed_url
->port
);
125 if (composed_url
->path
) {
126 add_assoc_string(z_composed_url
, "path", composed_url
->path
, 1);
128 if (composed_url
->query
) {
129 add_assoc_string(z_composed_url
, "query", composed_url
->query
, 1);
131 if (composed_url
->fragment
) {
132 add_assoc_string(z_composed_url
, "fragment", composed_url
->fragment
, 1);
134 php_url_free(composed_url
);
136 http_build_url(flags
, old_url
, new_url
, NULL
, &url_str
, &url_len
);
140 php_url_free(new_url
);
142 php_url_free(old_url
);
144 RETURN_STRINGL(url_str
, url_len
, 0);
148 /* {{{ proto string http_build_str(array query [, string prefix[, string arg_separator]])
150 * Opponent to parse_str().
152 PHP_FUNCTION(http_build_str
)
155 char *prefix
= NULL
, *arg_sep
= INI_STR("arg_separator.output");
156 int prefix_len
= 0, arg_sep_len
= strlen(arg_sep
);
159 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|ss", &formdata
, &prefix
, &prefix_len
, &arg_sep
, &arg_sep_len
) != SUCCESS
) {
164 arg_sep
= HTTP_URL_ARGSEP
;
165 arg_sep_len
= lenof(HTTP_URL_ARGSEP
);
168 phpstr_init(&formstr
);
169 if (SUCCESS
!= http_urlencode_hash_recursive(HASH_OF(formdata
), &formstr
, arg_sep
, arg_sep_len
, prefix
, prefix_len
)) {
174 phpstr_dtor(&formstr
);
178 RETURN_PHPSTR_VAL(&formstr
);
182 #define HTTP_DO_NEGOTIATE(type, supported, rs_array) \
185 if ((result = http_negotiate_ ##type(supported))) { \
190 if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
191 RETVAL_STRINGL(key, key_len-1, 0); \
197 zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \
200 zend_hash_destroy(result); \
201 FREE_HASHTABLE(result); \
206 zend_hash_internal_pointer_reset(Z_ARRVAL_P(supported)); \
207 if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(supported), (void **) &value)) { \
208 RETVAL_ZVAL(*value, 1, 0); \
217 FOREACH_VAL(pos, supported, value) { \
218 convert_to_string_ex(value); \
219 add_assoc_double(rs_array, Z_STRVAL_PP(value), 1.0); \
226 /* {{{ proto string http_negotiate_language(array supported[, array &result])
228 * This function negotiates the clients preferred language based on its
229 * Accept-Language HTTP header. The qualifier is recognized and languages
230 * without qualifier are rated highest. The qualifier will be decreased by
231 * 10% for partial matches (i.e. matching primary language).
233 * Expects an array as parameter containing the supported languages as values.
234 * If the optional second parameter is supplied, it will be filled with an
235 * array containing the negotiation results.
237 * Returns the negotiated language or the default language (i.e. first array entry)
253 * include './langs/'. http_negotiate_language($langs, $result) .'.php';
259 PHP_FUNCTION(http_negotiate_language
)
261 zval
*supported
, *rs_array
= NULL
;
263 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
269 array_init(rs_array
);
272 HTTP_DO_NEGOTIATE(language
, supported
, rs_array
);
276 /* {{{ proto string http_negotiate_charset(array supported[, array &result])
278 * This function negotiates the clients preferred charset based on its
279 * Accept-Charset HTTP header. The qualifier is recognized and charsets
280 * without qualifier are rated highest.
282 * Expects an array as parameter containing the supported charsets as values.
283 * If the optional second parameter is supplied, it will be filled with an
284 * array containing the negotiation results.
286 * Returns the negotiated charset or the default charset (i.e. first array entry)
293 * 'iso-8859-1', // default
299 * $pref = http_negotiate_charset($charsets, $result);
301 * if (strcmp($pref, 'iso-8859-1')) {
302 * iconv_set_encoding('internal_encoding', 'iso-8859-1');
303 * iconv_set_encoding('output_encoding', $pref);
304 * ob_start('ob_iconv_handler');
311 PHP_FUNCTION(http_negotiate_charset
)
313 zval
*supported
, *rs_array
= NULL
;
315 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
) != SUCCESS
) {
321 array_init(rs_array
);
324 HTTP_DO_NEGOTIATE(charset
, supported
, rs_array
);
328 /* {{{ proto string http_negotiate_ctype(array supported[, array &result])
330 * This function negotiates the clients preferred content type based on its
331 * Accept HTTP header. The qualifier is recognized and content types
332 * without qualifier are rated highest.
334 * Expects an array as parameter containing the supported content types as values.
335 * If the optional second parameter is supplied, it will be filled with an
336 * array containing the negotiation results.
338 * Returns the negotiated content type or the default content type
339 * (i.e. first array entry) if none match.
344 * $ctypes = array('application/xhtml+xml', 'text/html');
345 * http_send_content_type(http_negotiate_content_type($ctypes));
349 PHP_FUNCTION(http_negotiate_content_type
)
351 zval
*supported
, *rs_array
= NULL
;
353 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|z", &supported
, &rs_array
)) {
359 array_init(rs_array
);
362 HTTP_DO_NEGOTIATE(content_type
, supported
, rs_array
);
366 /* {{{ proto bool http_send_status(int status)
368 * Send HTTP status code.
370 * Expects an HTTP status code as parameter.
372 * Returns TRUE on success or FALSE on failure.
374 PHP_FUNCTION(http_send_status
)
378 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &status
) != SUCCESS
) {
381 if (status
< 100 || status
> 510) {
382 http_error_ex(HE_WARNING
, HTTP_E_HEADER
, "Invalid HTTP status code (100-510): %d", status
);
386 RETURN_SUCCESS(http_send_status(status
));
390 /* {{{ proto bool http_send_last_modified([int timestamp])
392 * Send a "Last-Modified" header with a valid HTTP date.
394 * Accepts a unix timestamp, converts it to a valid HTTP date and
395 * sends it as "Last-Modified" HTTP header. If timestamp is
396 * omitted, the current time will be sent.
398 * Returns TRUE on success or FALSE on failure.
400 PHP_FUNCTION(http_send_last_modified
)
404 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &t
) != SUCCESS
) {
409 t
= (long) HTTP_GET_REQUEST_TIME();
412 RETURN_SUCCESS(http_send_last_modified(t
));
416 /* {{{ proto bool http_send_content_type([string content_type = 'application/x-octetstream'])
418 * Send the Content-Type of the sent entity. This is particularly important
419 * if you use the http_send() API.
421 * Accepts an optional string parameter containing the desired content type
422 * (primary/secondary).
424 * Returns TRUE on success or FALSE on failure.
426 PHP_FUNCTION(http_send_content_type
)
428 char *ct
= "application/x-octetstream";
429 int ct_len
= lenof("application/x-octetstream");
431 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &ct
, &ct_len
) != SUCCESS
) {
435 RETURN_SUCCESS(http_send_content_type(ct
, ct_len
));
439 /* {{{ proto bool http_send_content_disposition(string filename[, bool inline = false])
441 * Send the Content-Disposition. The Content-Disposition header is very useful
442 * if the data actually sent came from a file or something similar, that should
443 * be "saved" by the client/user (i.e. by browsers "Save as..." popup window).
445 * Expects a string parameter specifying the file name the "Save as..." dialog
446 * should display. Optionally accepts a bool parameter, which, if set to true
447 * and the user agent knows how to handle the content type, will probably not
448 * cause the popup window to be shown.
450 * Returns TRUE on success or FALSE on failure.
452 PHP_FUNCTION(http_send_content_disposition
)
456 zend_bool send_inline
= 0;
458 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &filename
, &f_len
, &send_inline
) != SUCCESS
) {
461 RETURN_SUCCESS(http_send_content_disposition(filename
, f_len
, send_inline
));
465 /* {{{ proto bool http_match_modified([int timestamp[, bool for_range = false]])
467 * Matches the given unix timestamp against the clients "If-Modified-Since"
468 * resp. "If-Unmodified-Since" HTTP headers.
470 * Accepts a unix timestamp which should be matched. Optionally accepts an
471 * additional bool parameter, which if set to true will check the header
472 * usually used to validate HTTP ranges. If timestamp is omitted, the
473 * current time will be used.
475 * Returns TRUE if timestamp represents an earlier date than the header,
478 PHP_FUNCTION(http_match_modified
)
481 zend_bool for_range
= 0;
483 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|lb", &t
, &for_range
) != SUCCESS
) {
487 // current time if not supplied (senseless though)
489 t
= (long) HTTP_GET_REQUEST_TIME();
493 RETURN_BOOL(http_match_last_modified("HTTP_IF_UNMODIFIED_SINCE", t
));
495 RETURN_BOOL(http_match_last_modified("HTTP_IF_MODIFIED_SINCE", t
));
499 /* {{{ proto bool http_match_etag(string etag[, bool for_range = false])
501 * Matches the given ETag against the clients "If-Match" resp.
502 * "If-None-Match" HTTP headers.
504 * Expects a string parameter containing the ETag to compare. Optionally
505 * accepts a bool parameter, which, if set to true, will check the header
506 * usually used to validate HTTP ranges.
508 * Returns TRUE if ETag matches or the header contained the asterisk ("*"),
511 PHP_FUNCTION(http_match_etag
)
515 zend_bool for_range
= 0;
517 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|b", &etag
, &etag_len
, &for_range
) != SUCCESS
) {
522 RETURN_BOOL(http_match_etag("HTTP_IF_MATCH", etag
));
524 RETURN_BOOL(http_match_etag("HTTP_IF_NONE_MATCH", etag
));
528 /* {{{ proto bool http_cache_last_modified([int timestamp_or_expires]])
530 * Attempts to cache the sent entity by its last modification date.
532 * Accepts a unix timestamp as parameter which is handled as follows:
534 * If timestamp_or_expires is greater than 0, it is handled as timestamp
535 * and will be sent as date of last modification. If it is 0 or omitted,
536 * the current time will be sent as Last-Modified date. If it's negative,
537 * it is handled as expiration time in seconds, which means that if the
538 * requested last modification date is not between the calculated timespan,
539 * the Last-Modified header is updated and the actual body will be sent.
541 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
543 * A log entry will be written to the cache log if the INI entry
544 * http.cache_log is set and the cache attempt was successful.
546 PHP_FUNCTION(http_cache_last_modified
)
548 long last_modified
= 0, send_modified
= 0, t
;
551 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &last_modified
) != SUCCESS
) {
555 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
557 t
= (long) HTTP_GET_REQUEST_TIME();
560 if (!last_modified
) {
561 /* does the client have? (att: caching "forever") */
562 if ((zlm
= http_get_server_var("HTTP_IF_MODIFIED_SINCE"))) {
563 last_modified
= send_modified
= http_parse_date(Z_STRVAL_P(zlm
));
564 /* send current time */
568 /* negative value is supposed to be expiration time */
569 } else if (last_modified
< 0) {
572 /* send supplied time explicitly */
574 send_modified
= last_modified
;
577 RETURN_SUCCESS(http_cache_last_modified(last_modified
, send_modified
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
581 /* {{{ proto bool http_cache_etag([string etag])
583 * Attempts to cache the sent entity by its ETag, either supplied or generated
584 * by the hash algorithm specified by the INI setting "http.etag_mode".
586 * If the clients "If-None-Match" header matches the supplied/calculated
587 * ETag, the body is considered cached on the clients side and
588 * a "304 Not Modified" status code is issued.
590 * Returns FALSE on failure, or *exits* with "304 Not Modified" if the entity is cached.
592 * A log entry is written to the cache log if the INI entry
593 * "http.cache_log" is set and the cache attempt was successful.
595 PHP_FUNCTION(http_cache_etag
)
600 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &etag
, &etag_len
) != SUCCESS
) {
604 HTTP_CHECK_HEADERS_SENT(RETURN_FALSE
);
606 RETURN_SUCCESS(http_cache_etag(etag
, etag_len
, HTTP_DEFAULT_CACHECONTROL
, lenof(HTTP_DEFAULT_CACHECONTROL
)));
610 /* {{{ proto string ob_etaghandler(string data, int mode)
612 * For use with ob_start(). Output buffer handler generating an ETag with
613 * the hash algorithm specified with the INI setting "http.etag_mode".
615 PHP_FUNCTION(ob_etaghandler
)
621 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
625 Z_TYPE_P(return_value
) = IS_STRING
;
626 http_ob_etaghandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
630 /* {{{ proto void http_throttle(double sec[, int bytes = 40960])
632 * Sets the throttle delay and send buffer size for use with http_send() API.
633 * Provides a basic throttling mechanism, which will yield the current process
634 * resp. thread until the entity has been completely sent, though.
636 * Expects a double parameter specifying the seconds too sleep() after
637 * each chunk sent. Additionally accepts an optional int parameter
638 * representing the chunk size in bytes.
644 * # http_throttle(1, 20000);
645 * # http_throttle(0.5, 10000);
646 * # http_throttle(0.1, 2000);
647 * http_send_file('document.pdf');
651 PHP_FUNCTION(http_throttle
)
653 long chunk_size
= HTTP_SENDBUF_SIZE
;
656 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "d|l", &interval
, &chunk_size
)) {
660 HTTP_G(send
).throttle_delay
= interval
;
661 HTTP_G(send
).buffer_size
= chunk_size
;
665 /* {{{ proto void http_redirect([string url[, array params[, bool session = false[, int status = 302]]]])
667 * Redirect to the given url.
669 * The supplied url will be expanded with http_build_url(), the params array will
670 * be treated with http_build_query() and the session identification will be appended
671 * if session is true.
673 * The HTTP response code will be set according to status.
674 * You can use one of the following constants for convenience:
675 * - HTTP_REDIRECT 302 Found for GET/HEAD, else 303 See Other
676 * - HTTP_REDIRECT_PERM 301 Moved Permanently
677 * - HTTP_REDIRECT_FOUND 302 Found
678 * - HTTP_REDIRECT_POST 303 See Other
679 * - HTTP_REDIRECT_PROXY 305 Use Proxy
680 * - HTTP_REDIRECT_TEMP 307 Temporary Redirect
682 * Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
683 * for which redirect response code to use in which situation.
685 * To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed,
686 * if the client doesn't redirect immediately, and the request method was
687 * another one than HEAD.
689 * Returns FALSE on failure, or *exits* on success.
691 * A log entry will be written to the redirect log, if the INI entry
692 * "http.redirect_log" is set and the redirect attempt was successful.
694 PHP_FUNCTION(http_redirect
)
697 size_t query_len
= 0;
698 zend_bool session
= 0, free_params
= 0;
700 long status
= HTTP_REDIRECT
;
701 char *query
= NULL
, *url
= NULL
, *URI
, *LOC
, *RED
= NULL
;
703 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|sa!/bl", &url
, &url_len
, ¶ms
, &session
, &status
) != SUCCESS
) {
707 #ifdef HAVE_PHP_SESSION
708 /* append session info */
712 MAKE_STD_ZVAL(params
);
715 if (PS(session_status
) == php_session_active
) {
716 if (add_assoc_string(params
, PS(session_name
), PS(id
), 1) != SUCCESS
) {
717 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Could not append session information");
723 /* treat params array with http_build_query() */
725 if (SUCCESS
!= http_urlencode_hash_ex(Z_ARRVAL_P(params
), 0, NULL
, 0, &query
, &query_len
)) {
737 URI
= http_absolute_url(url
);
740 spprintf(&LOC
, 0, "Location: %s?%s", URI
, query
);
742 spprintf(&RED
, 0, "Redirecting to <a href=\"%s?%s\">%s?%s</a>.\n", URI
, query
, URI
, query
);
745 spprintf(&LOC
, 0, "Location: %s", URI
);
747 spprintf(&RED
, 0, "Redirecting to <a href=\"%s\">%s</a>.\n", URI
, URI
);
763 RETVAL_SUCCESS(http_send_status_header(status
, LOC
));
768 case HTTP_REDIRECT_PERM
:
769 case HTTP_REDIRECT_FOUND
:
770 case HTTP_REDIRECT_POST
:
771 case HTTP_REDIRECT_PROXY
:
772 case HTTP_REDIRECT_TEMP
:
777 http_error_ex(HE_NOTICE
, HTTP_E_RUNTIME
, "Unsupported redirection status code: %ld", status
);
779 if ( SG(request_info
).request_method
&&
780 strcasecmp(SG(request_info
).request_method
, "HEAD") &&
781 strcasecmp(SG(request_info
).request_method
, "GET")) {
782 status
= HTTP_REDIRECT_POST
;
784 status
= HTTP_REDIRECT_FOUND
;
789 RETURN_SUCCESS(http_exit_ex(status
, LOC
, RED
, 1));
793 /* {{{ proto bool http_send_data(string data)
795 * Sends raw data with support for (multiple) range requests.
797 * Returns TRUE on success, or FALSE on failure.
799 PHP_FUNCTION(http_send_data
)
803 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z", &zdata
) != SUCCESS
) {
807 convert_to_string_ex(&zdata
);
808 RETURN_SUCCESS(http_send_data(Z_STRVAL_P(zdata
), Z_STRLEN_P(zdata
)));
812 /* {{{ proto bool http_send_file(string file)
814 * Sends a file with support for (multiple) range requests.
816 * Expects a string parameter referencing the file to send.
818 * Returns TRUE on success, or FALSE on failure.
820 PHP_FUNCTION(http_send_file
)
825 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &file
, &flen
) != SUCCESS
) {
832 RETURN_SUCCESS(http_send_file(file
));
836 /* {{{ proto bool http_send_stream(resource stream)
838 * Sends an already opened stream with support for (multiple) range requests.
840 * Expects a resource parameter referencing the stream to read from.
842 * Returns TRUE on success, or FALSE on failure.
844 PHP_FUNCTION(http_send_stream
)
849 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &zstream
) != SUCCESS
) {
853 php_stream_from_zval(file
, &zstream
);
854 RETURN_SUCCESS(http_send_stream(file
));
858 /* {{{ proto string http_chunked_decode(string encoded)
860 * Decodes a string that was HTTP-chunked encoded.
862 * Expects a chunked encoded string as parameter.
864 * Returns the decoded string on success or FALSE on failure.
866 PHP_FUNCTION(http_chunked_decode
)
868 char *encoded
= NULL
, *decoded
= NULL
;
869 size_t decoded_len
= 0;
872 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &encoded
, &encoded_len
) != SUCCESS
) {
876 if (NULL
!= http_encoding_dechunk(encoded
, encoded_len
, &decoded
, &decoded_len
)) {
877 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
884 /* {{{ proto object http_parse_message(string message)
886 * Parses (a) http_message(s) into a simple recursive object structure.
888 * Expects a string parameter containing a single HTTP message or
889 * several consecutive HTTP messages.
891 * Returns an hierarchical object structure of the parsed messages.
896 * print_r(http_parse_message(http_get(URL, array('redirect' => 3)));
901 * [httpVersion] => 1.1
902 * [responseCode] => 200
905 * [Content-Length] => 3
909 * [parentMessage] => stdClass object
912 * [httpVersion] => 1.1
913 * [responseCode] => 302
916 * [Content-Length] => 0
920 * [parentMessage] => ...
926 PHP_FUNCTION(http_parse_message
)
930 http_message
*msg
= NULL
;
932 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &message
, &message_len
)) {
936 if ((msg
= http_message_parse(message
, message_len
))) {
937 object_init(return_value
);
938 http_message_tostruct_recursive(msg
, return_value
);
939 http_message_free(&msg
);
946 /* {{{ proto array http_parse_headers(string header)
948 * Parses HTTP headers into an associative array.
950 * Expects a string parameter containing HTTP headers.
952 * Returns an array on success, or FALSE on failure.
957 * $headers = "content-type: text/html; charset=UTF-8\r\n".
958 * "Server: Funky/1.0\r\n".
959 * "Set-Cookie: foo=bar\r\n".
960 * "Set-Cookie: baz=quux\r\n".
961 * "Folded: works\r\n\ttoo\r\n";
962 * print_r(http_parse_headers($headers));
966 * [Content-Type] => text/html; chatset=UTF-8
967 * [Server] => Funky/1.0
968 * [Set-Cookie] => Array
979 PHP_FUNCTION(http_parse_headers
)
984 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &header
, &header_len
)) {
988 array_init(return_value
);
989 if (SUCCESS
!= http_parse_headers(header
, return_value
)) {
990 zval_dtor(return_value
);
996 /* {{{ proto object http_parse_cookie(string cookie)
998 * Parses HTTP cookies like sent in a response into a struct.
1000 * Expects a string as parameter containing the value of a Set-Cookie response header.
1002 * Returns an stdClass object with the cookie params as properties on success or FALSE on failure.
1007 * print_r(http_parse_cookie("foo=bar; path=/"));
1018 PHP_FUNCTION(http_parse_cookie
)
1023 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &cookie
, &cookie_len
)) {
1027 object_init(return_value
);
1028 if (SUCCESS
!= http_parse_cookie(cookie
, HASH_OF(return_value
))) {
1029 zval_dtor(return_value
);
1034 /* {{{ proto array http_get_request_headers(void)
1036 * Get a list of incoming HTTP headers.
1038 * Returns an associative array of incoming request headers.
1040 PHP_FUNCTION(http_get_request_headers
)
1044 array_init(return_value
);
1045 http_get_request_headers(return_value
);
1049 /* {{{ proto string http_get_request_body(void)
1051 * Get the raw request body (e.g. POST or PUT data).
1053 * This function can not be used after http_get_request_body_stream()
1054 * if the request method was another than POST.
1056 * Returns the raw request body as string on success or NULL on failure.
1058 PHP_FUNCTION(http_get_request_body
)
1065 if (SUCCESS
== http_get_request_body(&body
, &length
)) {
1066 RETURN_STRINGL(body
, (int) length
, 0);
1073 /* {{{ proto resource http_get_request_body_stream(void)
1075 * Create a stream to read the raw request body (e.g. POST or PUT data).
1077 * This function can only be used once if the request method was another than POST.
1079 * Returns the raw request body as stream on success or NULL on failure.
1081 PHP_FUNCTION(http_get_request_body_stream
)
1087 if ((s
= http_get_request_body_stream())) {
1088 php_stream_to_zval(s
, return_value
);
1090 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Failed to create request body stream");
1096 /* {{{ proto bool http_match_request_header(string header, string value[, bool match_case = false])
1098 * Match an incoming HTTP header.
1100 * Expects two string parameters representing the header name (case-insensitive)
1101 * and the header value that should be compared. The case sensitivity of the
1102 * header value depends on the additional optional bool parameter accepted.
1104 * Returns TRUE if header value matches, else FALSE.
1106 PHP_FUNCTION(http_match_request_header
)
1108 char *header
, *value
;
1109 int header_len
, value_len
;
1110 zend_bool match_case
= 0;
1112 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|b", &header
, &header_len
, &value
, &value_len
, &match_case
)) {
1116 RETURN_BOOL(http_match_request_header_ex(header
, value
, match_case
));
1121 #ifdef HTTP_HAVE_CURL
1123 #define RETVAL_RESPONSE_OR_BODY(request) \
1127 /* check if only the body should be returned */ \
1128 if (options && (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), "bodyonly", sizeof("bodyonly"), (void **) &bodyonly)) && zval_is_true(*bodyonly)) { \
1129 http_message *msg = http_message_parse(PHPSTR_VAL(&request.conv.response), PHPSTR_LEN(&request.conv.response)); \
1132 RETVAL_STRINGL(PHPSTR_VAL(&msg->body), PHPSTR_LEN(&msg->body), 1); \
1133 http_message_free(&msg); \
1136 RETVAL_STRINGL(request.conv.response.data, request.conv.response.used, 1); \
1140 /* {{{ proto string http_get(string url[, array options[, array &info]])
1142 * Performs an HTTP GET request on the supplied url.
1144 * The second parameter, if set, is expected to be an associative
1145 * array where the following keys will be recognized:
1147 * - redirect: int, whether and how many redirects to follow
1148 * - unrestrictedauth: bool, whether to continue sending credentials on
1149 * redirects to a different host
1150 * - proxyhost: string, proxy host in "host[:port]" format
1151 * - proxyport: int, use another proxy port as specified in proxyhost
1152 * - proxyauth: string, proxy credentials in "user:pass" format
1153 * - proxyauthtype: int, HTTP_AUTH_BASIC and/or HTTP_AUTH_NTLM
1154 * - httpauth: string, http credentials in "user:pass" format
1155 * - httpauthtype: int, HTTP_AUTH_BASIC, DIGEST and/or NTLM
1156 * - compress: bool, whether to allow gzip/deflate content encoding
1157 * - port: int, use another port as specified in the url
1158 * - referer: string, the referer to send
1159 * - useragent: string, the user agent to send
1160 * (defaults to PECL::HTTP/version (PHP/version)))
1161 * - headers: array, list of custom headers as associative array
1162 * like array("header" => "value")
1163 * - cookies: array, list of cookies as associative array
1164 * like array("cookie" => "value")
1165 * - cookiestore: string, path to a file where cookies are/will be stored
1166 * - resume: int, byte offset to start the download from;
1167 * if the server supports ranges
1168 * - maxfilesize: int, maximum file size that should be downloaded;
1169 * has no effect, if the size of the requested entity is not known
1170 * - lastmodified: int, timestamp for If-(Un)Modified-Since header
1171 * - etag: string, quoted etag for If-(None-)Match header
1172 * - timeout: int, seconds the request may take
1173 * - connecttimeout: int, seconds the connect may take
1174 * - onprogress: mixed, progress callback
1175 * - ssl: array, with the following options:
1176 * cert: string, path to certificate
1177 * certtype: string, type of certificate
1178 * certpasswd: string, password for certificate
1179 * key: string, path to key
1180 * keytype: string, type of key
1181 * keypasswd: string, pasword for key
1182 * engine: string, ssl engine to use
1183 * version: int, ssl version to use
1184 * verifypeer: bool, whether to verify the peer
1185 * verifyhost: bool whether to verify the host
1186 * cipher_list: string, list of allowed ciphers
1189 * random_file: string
1193 * The optional third parameter will be filled with some additional information
1194 * in form of an associative array, if supplied, like the following example:
1198 * 'effective_url' => 'http://localhost',
1199 * 'response_code' => 403,
1200 * 'total_time' => 0.017,
1201 * 'namelookup_time' => 0.013,
1202 * 'connect_time' => 0.014,
1203 * 'pretransfer_time' => 0.014,
1204 * 'size_upload' => 0,
1205 * 'size_download' => 202,
1206 * 'speed_download' => 11882,
1207 * 'speed_upload' => 0,
1208 * 'header_size' => 145,
1209 * 'request_size' => 62,
1210 * 'ssl_verifyresult' => 0,
1212 * 'content_length_download' => 202,
1213 * 'content_length_upload' => 0,
1214 * 'starttransfer_time' => 0.017,
1215 * 'content_type' => 'text/html; charset=iso-8859-1',
1216 * 'redirect_time' => 0,
1217 * 'redirect_count' => 0,
1218 * 'http_connectcode' => 0,
1219 * 'httpauth_avail' => 0,
1220 * 'proxyauth_avail' => 0,
1225 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1227 PHP_FUNCTION(http_get
)
1229 zval
*options
= NULL
, *info
= NULL
;
1232 http_request request
;
1234 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1245 http_request_init_ex(&request
, NULL
, HTTP_GET
, URL
);
1246 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1247 http_request_exec(&request
);
1249 http_request_info(&request
, Z_ARRVAL_P(info
));
1251 RETVAL_RESPONSE_OR_BODY(request
);
1253 http_request_dtor(&request
);
1257 /* {{{ proto string http_head(string url[, array options[, array &info]])
1259 * Performs an HTTP HEAD request on the supplied url.
1261 * See http_get() for a full list of available parameters and options.
1263 * Returns the HTTP response as string on success, or FALSE on failure.
1265 PHP_FUNCTION(http_head
)
1267 zval
*options
= NULL
, *info
= NULL
;
1270 http_request request
;
1272 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|a/!z", &URL
, &URL_len
, &options
, &info
) != SUCCESS
) {
1283 http_request_init_ex(&request
, NULL
, HTTP_HEAD
, URL
);
1284 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1285 http_request_exec(&request
);
1287 http_request_info(&request
, Z_ARRVAL_P(info
));
1289 RETVAL_RESPONSE_OR_BODY(request
);
1291 http_request_dtor(&request
);
1295 /* {{{ proto string http_post_data(string url, string data[, array options[, array &info]])
1297 * Performs an HTTP POST request on the supplied url.
1299 * Expects a string as second parameter containing the pre-encoded post data.
1300 * See http_get() for a full list of available parameters and options.
1302 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1304 PHP_FUNCTION(http_post_data
)
1306 zval
*options
= NULL
, *info
= NULL
;
1307 char *URL
, *postdata
;
1308 int postdata_len
, URL_len
;
1309 http_request_body body
;
1310 http_request request
;
1312 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &postdata
, &postdata_len
, &options
, &info
) != SUCCESS
) {
1323 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1324 request
.body
= http_request_body_init_ex(&body
, HTTP_REQUEST_BODY_CSTRING
, postdata
, postdata_len
, 0);
1325 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1326 http_request_exec(&request
);
1328 http_request_info(&request
, Z_ARRVAL_P(info
));
1330 RETVAL_RESPONSE_OR_BODY(request
);
1332 http_request_dtor(&request
);
1336 /* {{{ proto string http_post_fields(string url, array data[, array files[, array options[, array &info]]])
1338 * Performs an HTTP POST request on the supplied url.
1340 * Expects an associative array as second parameter, which will be
1341 * www-form-urlencoded. See http_get() for a full list of available options.
1343 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1345 PHP_FUNCTION(http_post_fields
)
1347 zval
*options
= NULL
, *info
= NULL
, *fields
, *files
= NULL
;
1350 http_request_body body
;
1351 http_request request
;
1353 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sa|aa/!z", &URL
, &URL_len
, &fields
, &files
, &options
, &info
) != SUCCESS
) {
1357 if (!http_request_body_fill(&body
, Z_ARRVAL_P(fields
), files
? Z_ARRVAL_P(files
) : NULL
)) {
1368 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1369 request
.body
= &body
;
1370 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1371 http_request_exec(&request
);
1373 http_request_info(&request
, Z_ARRVAL_P(info
));
1375 RETVAL_RESPONSE_OR_BODY(request
);
1377 http_request_dtor(&request
);
1381 /* {{{ proto string http_put_file(string url, string file[, array options[, array &info]])
1383 * Performs an HTTP PUT request on the supplied url.
1385 * Expects the second parameter to be a string referencing the file to upload.
1386 * See http_get() for a full list of available options.
1388 * Returns the HTTP response(s) as string on success, or FALSE on failure.
1390 PHP_FUNCTION(http_put_file
)
1394 zval
*options
= NULL
, *info
= NULL
;
1396 php_stream_statbuf ssb
;
1397 http_request_body body
;
1398 http_request request
;
1400 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|a/!z", &URL
, &URL_len
, &file
, &f_len
, &options
, &info
)) {
1404 if (!(stream
= php_stream_open_wrapper(file
, "rb", REPORT_ERRORS
|ENFORCE_SAFE_MODE
, NULL
))) {
1407 if (php_stream_stat(stream
, &ssb
)) {
1408 php_stream_close(stream
);
1419 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1421 body
.size
= ssb
.sb
.st_size
;
1423 http_request_init_ex(&request
, NULL
, HTTP_PUT
, URL
);
1424 request
.body
= &body
;
1425 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1426 http_request_exec(&request
);
1428 http_request_info(&request
, Z_ARRVAL_P(info
));
1430 RETVAL_RESPONSE_OR_BODY(request
);
1432 http_request_body_dtor(&body
);
1433 request
.body
= NULL
;
1434 http_request_dtor(&request
);
1438 /* {{{ proto string http_put_stream(string url, resource stream[, array options[, array &info]])
1440 * Performs an HTTP PUT request on the supplied url.
1442 * Expects the second parameter to be a resource referencing an already
1443 * opened stream, from which the data to upload should be read.
1444 * See http_get() for a full list of available options.
1446 * Returns the HTTP response(s) as string on success. or FALSE on failure.
1448 PHP_FUNCTION(http_put_stream
)
1450 zval
*resource
, *options
= NULL
, *info
= NULL
;
1454 php_stream_statbuf ssb
;
1455 http_request_body body
;
1456 http_request request
;
1458 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sr|a/!z", &URL
, &URL_len
, &resource
, &options
, &info
)) {
1462 php_stream_from_zval(stream
, &resource
);
1463 if (php_stream_stat(stream
, &ssb
)) {
1474 body
.type
= HTTP_REQUEST_BODY_UPLOADFILE
;
1476 body
.size
= ssb
.sb
.st_size
;
1478 http_request_init_ex(&request
, NULL
, HTTP_POST
, URL
);
1479 request
.body
= &body
;
1480 if (SUCCESS
== http_request_prepare(&request
, options
?Z_ARRVAL_P(options
):NULL
)) {
1481 http_request_exec(&request
);
1483 http_request_info(&request
, Z_ARRVAL_P(info
));
1485 RETVAL_RESPONSE_OR_BODY(request
);
1487 request
.body
= NULL
;
1488 http_request_dtor(&request
);
1491 #endif /* HTTP_HAVE_CURL */
1494 /* {{{ proto int http_request_method_register(string method)
1496 * Register a custom request method.
1498 * Expects a string parameter containing the request method name to register.
1500 * Returns the ID of the request method on success, or FALSE on failure.
1502 PHP_FUNCTION(http_request_method_register
)
1508 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &method
, &method_len
)) {
1511 if ((existing
= http_request_method_exists(1, 0, method
))) {
1512 RETURN_LONG((long) existing
);
1515 RETVAL_LONG((long) http_request_method_register(method
, method_len
));
1519 /* {{{ proto bool http_request_method_unregister(mixed method)
1521 * Unregister a previously registered custom request method.
1523 * Expects either the request method name or ID.
1525 * Returns TRUE on success, or FALSE on failure.
1527 PHP_FUNCTION(http_request_method_unregister
)
1531 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1535 switch (Z_TYPE_P(method
))
1538 convert_to_string(method
);
1540 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1541 convert_to_long(method
);
1544 if (!(mn
= http_request_method_exists(1, 0, Z_STRVAL_P(method
)))) {
1548 ZVAL_LONG(method
, (long)mn
);
1551 RETURN_SUCCESS(http_request_method_unregister(Z_LVAL_P(method
)));
1558 /* {{{ proto int http_request_method_exists(mixed method)
1560 * Check if a request method is registered (or available by default).
1562 * Expects either the request method name or ID as parameter.
1564 * Returns TRUE if the request method is known, else FALSE.
1566 PHP_FUNCTION(http_request_method_exists
)
1571 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &method
)) {
1575 switch (Z_TYPE_P(method
))
1578 convert_to_string(method
);
1580 if (is_numeric_string(Z_STRVAL_P(method
), Z_STRLEN_P(method
), NULL
, NULL
, 1)) {
1581 convert_to_long(method
);
1583 RETURN_LONG((long) http_request_method_exists(1, 0, Z_STRVAL_P(method
)));
1586 RETURN_LONG((long) http_request_method_exists(0, (int) Z_LVAL_P(method
), NULL
));
1594 /* {{{ proto string http_request_method_name(int method)
1596 * Get the literal string representation of a standard or registered request method.
1598 * Expects the request method ID as parameter.
1600 * Returns the request method name as string on success, or FALSE on failure.
1602 PHP_FUNCTION(http_request_method_name
)
1607 if ((SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &method
)) || (method
< 0)) {
1611 RETURN_STRING(estrdup(http_request_method_name((int) method
)), 0);
1617 #ifdef HTTP_HAVE_ZLIB
1619 /* {{{ proto string http_deflate(string data[, int flags = 0])
1621 * Compress data with gzip, zlib AKA deflate or raw deflate encoding.
1623 * Expects the first parameter to be a string containing the data that should
1626 * Returns the encoded string on success, or NULL on failure.
1628 PHP_FUNCTION(http_deflate
)
1636 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|l", &data
, &data_len
, &flags
)) {
1640 if (SUCCESS
== http_encoding_deflate(flags
, data
, data_len
, &encoded
, &encoded_len
)) {
1641 RETURN_STRINGL(encoded
, (int) encoded_len
, 0);
1647 /* {{{ proto string http_inflate(string data)
1649 * Decompress data compressed with either gzip, deflate AKA zlib or raw
1652 * Expects a string as parameter containing the compressed data.
1654 * Returns the decoded string on success, or NULL on failure.
1656 PHP_FUNCTION(http_inflate
)
1663 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &data
, &data_len
)) {
1667 if (SUCCESS
== http_encoding_inflate(data
, data_len
, &decoded
, &decoded_len
)) {
1668 RETURN_STRINGL(decoded
, (int) decoded_len
, 0);
1674 /* {{{ proto string ob_deflatehandler(string data, int mode)
1676 * For use with ob_start(). The deflate output buffer handler can only be used once.
1677 * It conflicts with ob_gzhandler and zlib.output_compression as well and should
1678 * not be used after ext/mbstrings mb_output_handler and ext/sessions URL-Rewriter (AKA
1679 * session.use_trans_sid).
1681 PHP_FUNCTION(ob_deflatehandler
)
1687 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1691 http_ob_deflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1692 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1696 /* {{{ proto string ob_inflatehandler(string data, int mode)
1698 * For use with ob_start(). Same restrictions as with ob_deflatehandler apply.
1700 PHP_FUNCTION(ob_inflatehandler
)
1706 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sl", &data
, &data_len
, &mode
)) {
1710 http_ob_inflatehandler(data
, data_len
, &Z_STRVAL_P(return_value
), (uint
*) &Z_STRLEN_P(return_value
), mode
);
1711 Z_TYPE_P(return_value
) = Z_STRVAL_P(return_value
) ? IS_STRING
: IS_NULL
;
1715 #endif /* HTTP_HAVE_ZLIB */
1718 /* {{{ proto int http_support([int feature = 0])
1720 * Check for feature that require external libraries.
1722 * Accepts an optional in parameter specifying which feature to probe for.
1723 * If the parameter is 0 or omitted, the return value contains a bitmask of
1724 * all supported features that depend on external libraries.
1726 * Available features to probe for are:
1728 * <li> HTTP_SUPPORT: always set
1729 * <li> HTTP_SUPPORT_REQUESTS: whether ext/http was linked against libcurl,
1730 * and HTTP requests can be issued
1731 * <li> HTTP_SUPPORT_SSLREQUESTS: whether libcurl was linked against openssl,
1732 * and SSL requests can be issued
1733 * <li> HTTP_SUPPORT_ENCODINGS: whether ext/http was linked against zlib,
1734 * and compressed HTTP responses can be decoded
1735 * <li> HTTP_SUPPORT_MAGICMIME: whether ext/http was linked against libmagic,
1736 * and the HttpResponse::guessContentType() method is usable
1739 * Returns int, whether requested feature is supported, or a bitmask with
1740 * all supported features.
1742 PHP_FUNCTION(http_support
)
1748 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|l", &feature
)) {
1749 RETVAL_LONG(http_support(feature
));
1754 PHP_FUNCTION(http_test
)
1763 * vim600: noet sw=4 ts=4 fdm=marker
1764 * vim<600: noet sw=4 ts=4