--- /dev/null
+// config.w32 for pecl/http\r
+// $Id$\r
+\r
+ARG_ENABLE("http", "whether to enable extended HTTP support", "no");\r
+\r
+function check_for_main_ext(ext, header)\r
+{\r
+ if (!header) {\r
+ header = "php_"+ ext +".h";\r
+ }\r
+\r
+ /* When in configure, we're always in the root of PHP source */\r
+ var ext_path = "ext\\" + ext;\r
+ \r
+ STDOUT.Write("Checking for ext/"+ ext +" ... ");\r
+\r
+ if (FSO.FileExists(ext_path + "\\" + header)) {\r
+ STDOUT.WriteLine(ext_path);\r
+ return ext_path;\r
+ }\r
+\r
+ STDOUT.WriteLine("<not found>");\r
+ return false;\r
+}\r
+\r
+function check_for_pecl_ext(ext, header)\r
+{\r
+ if (!header) {\r
+ header = "php_"+ ext +".h";\r
+ }\r
+ \r
+ var g;\r
+ var s = ext +"\\"+ header;\r
+ \r
+ STDOUT.Write("Checking for pecl/"+ ext +" ... ");\r
+ if ( (g = glob(configure_module_dirname +"\\..\\"+ s)) ||\r
+ (g = glob(configure_module_dirname +"\\..\\..\\..\\pecl\\"+ s))) {\r
+ var f = g[0].substr(0, g[0].length - header.length - 1);\r
+ STDOUT.WriteLine(f);\r
+ return f;\r
+ }\r
+ STDOUT.WriteLine("<not found>");\r
+ return false;\r
+}\r
+\r
+if (PHP_HTTP != "no") {\r
+\r
+ EXTENSION("http",\r
+ "php_http_buffer.c php_http.c php_http_client.c php_http_curl_client.c php_http_client_datashare.c " +\r
+ "php_http_curl_client_datashare.c php_http_client_factory.c php_http_client_interface.c " +\r
+ "php_http_client_pool.c php_http_curl_client_pool.c php_http_client_request.c " +\r
+ "php_http_client_response.c php_http_cookie.c php_http_curl.c php_http_encoding.c " +\r
+ "php_http_env.c php_http_env_request.c php_http_env_response.c php_http_etag.c " +\r
+ "php_http_exception.c php_http_filter.c php_http_header_parser.c php_http_headers.c " +\r
+ "php_http_info.c php_http_message_body.c php_http_message.c php_http_message_parser.c " +\r
+ "php_http_misc.c php_http_negotiate.c php_http_object.c php_http_params.c " +\r
+ "php_http_persistent_handle.c php_http_property_proxy.c php_http_querystring.c " +\r
+ "php_http_resource_factory.c php_http_strlist.c php_http_url.c php_http_version.c");\r
+\r
+ AC_DEFINE("HAVE_HTTP", 1, "Have extended HTTP support");\r
+ AC_DEFINE("HTTP_SHARED_DEPS", 1, "Depend on shared extensions");\r
+ \r
+ AC_DEFINE("HAVE_GETHOSTNAME", 1);\r
+ AC_DEFINE("HAVE_GETSERVBYPORT", 1);\r
+ AC_DEFINE("HAVE_GETSERVBYNAME", 1);\r
+ \r
+ if (PHP_DEBUG != "no") {\r
+ ADD_FLAG("CFLAGS_HTTP", "/W3");\r
+ }\r
+ \r
+ if (CHECK_HEADER_ADD_INCLUDE('zlib.h', 'CFLAGS_HTTP', '..\\zlib;' + php_usual_include_suspects)) {\r
+ AC_DEFINE('HTTP_HAVE_ZLIB', 1, "Have zlib library");\r
+ ADD_FLAG("LDFLAGS_HTTP", "/FORCE:MULTIPLE");\r
+ } else {\r
+ WARNING("zlib encoding functions not enabled; libraries and headers not found");\r
+ }\r
+ \r
+ if (typeof(PHP_HASH) != "undefined" && PHP_HASH != "no") {\r
+ var f;\r
+ \r
+ if ((f = check_for_pecl_ext("hash")) || (f = check_for_main_ext("hash"))) {\r
+ ADD_FLAG("CFLAGS_HTTP", '/I "' + f + '" /DHTTP_HAVE_PHP_HASH_H=1');\r
+ ADD_EXTENSION_DEP("http", "hash", true);\r
+ }\r
+ }\r
+ \r
+ if (PHP_SESSION != "no") {\r
+ ADD_EXTENSION_DEP("http", "session", true);\r
+ }\r
+ \r
+ if (PHP_ICONV != "no") {\r
+ ADD_EXTENSION_DEP("http", "iconv", true);\r
+ }\r
+ \r
+ CURL_LIB="libcurl_a.lib;libcurl.lib;" + (PHP_DEBUG != "no" ? "libcurld.lib":"libcurl.lib");\r
+ if (CHECK_HEADER_ADD_INCLUDE("curl/curl.h", "CFLAGS_HTTP") &&\r
+ CHECK_HEADER_ADD_INCLUDE("openssl/crypto.h", "CFLAGS_HTTP") &&\r
+ CHECK_LIB(CURL_LIB, "http", PHP_HTTP) &&\r
+ CHECK_LIB("ssleay32.lib", "http", PHP_HTTP) &&\r
+ CHECK_LIB("libeay32.lib", "http", PHP_HTTP) &&\r
+ CHECK_LIB("zlib.lib;zlib_a.lib", "http", PHP_HTTP) &&\r
+ CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {\r
+ AC_DEFINE("PHP_HTTP_HAVE_CURL", 1, "Have CURL library");\r
+ AC_DEFINE("PHP_HTTP_HAVE_SSL", 1, "Have SSL");\r
+ AC_DEFINE("PHP_HAVE_CURL_MULTI_STRERROR", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_SHARE_STRERROR", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_EASY_STRERROR", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_EASY_RESET", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_GETFORMDATA", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_FORMGET", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_MULTI_SETOPT", 1, "");\r
+ AC_DEFINE("PHP_HAVE_CURL_MULTI_TIMEOUT", 1, "");\r
+ } else {\r
+ WARNING("curl convenience functions not enabled; libraries and headers not found");\r
+ }\r
+}\r
#include "config.h"
#endif
+#ifndef PHP_WIN32
#include <php_config.h>
+#endif
#include <php.h>
#include <SAPI.h>
#include <zend_interfaces.h>
-#if defined(PHP_WIN32)
-# if defined(PHP_HTTP_EXPORTS)
-# define PHP_HTTP_API __declspec(dllexport)
-# elif defined(COMPILE_DL_HTTP)
-# define PHP_HTTP_API __declspec(dllimport)
-# else
-# define PHP_HTTP_API
-# endif
+#ifdef PHP_WIN32
+# define PHP_HTTP_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_HTTP_API __attribute__ ((visibility("default")))
#else
-# define PHP_HTTP_API
+# define PHP_HTTP_API
#endif
/* make functions that return SUCCESS|FAILURE more obvious */
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
-
+#endif
ov.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
ov.handlers = &php_http_client_object_handlers;
PHP_HTTP_ARG_OBJ(http\\Client, client, 0)
PHP_HTTP_END_ARGS;
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC);
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
+#if PHP_VERSION_ID >= 50400
+, const zend_literal *literal_key
+#endif
+TSRMLS_DC);
static zend_class_entry *php_http_client_datashare_class_entry;
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC);
ov.handlers = &php_http_client_datashare_object_handlers;
efree(o);
}
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC)
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
+#if PHP_VERSION_ID >= 50400
+, const zend_literal *literal_key
+#endif
+TSRMLS_DC)
{
zend_property_info *pi;
}
}
- zend_get_std_object_handlers()->write_property(object, member, value, literal_key TSRMLS_CC);
+ zend_get_std_object_handlers()->write_property(object, member, value
+#if PHP_VERSION_ID >= 50400
+ , literal_key
+#endif
+ TSRMLS_CC);
}
-static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member, const zend_literal *literal_key TSRMLS_DC)
+static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member
+#if PHP_VERSION_ID >= 50400
+, const zend_literal *literal_key
+#endif
+TSRMLS_DC)
{
zend_property_info *pi;
return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself;
}
- return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member, literal_key TSRMLS_CC);
+ return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member
+#if PHP_VERSION_ID >= 50400
+ , literal_key
+#endif
+ TSRMLS_CC);
}
o = ecalloc(1, sizeof(php_http_client_pool_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (!(o->pool = p)) {
o->pool = php_http_client_pool_init(NULL, &php_http_client_pool_user_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(sizeof(*o), 1);
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (list) {
o->list = list;
o = ecalloc(1, sizeof(php_http_client_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (!(o->client = r)) {
o->client = php_http_client_init(NULL, &php_http_curl_client_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (share) {
o->share = share;
o = ecalloc(1, sizeof(php_http_client_pool_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (!(o->pool = p)) {
o->pool = php_http_client_pool_init(NULL, &php_http_curl_client_pool_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (ptr) {
*ptr = o;
#ifndef PHP_HTTP_ENCODING_H
#define PHP_HTTP_ENCODING_H
+#include <zlib.h>
+
extern PHP_MINIT_FUNCTION(http_encoding);
extern PHP_RINIT_FUNCTION(http_encoding);
extern PHP_RSHUTDOWN_FUNCTION(http_encoding);
/* we really only need to flush when throttling is enabled,
because we push the data as fast as possible anyway if not */
if (r->throttle.delay >= PHP_HTTP_DIFFSEC) {
+#if PHP_VERSION_ID >= 50400
if (php_output_get_level(TSRMLS_C)) {
php_output_flush_all(TSRMLS_C);
}
if (!(php_output_get_status(TSRMLS_C) & PHP_OUTPUT_IMPLICITFLUSH)) {
sapi_flush(TSRMLS_C);
}
+#endif
php_http_sleep(r->throttle.delay);
}
return len;
#define php_http_env_response_send_done(r) php_http_env_response_send_data((r), NULL, 0)
static STATUS php_http_env_response_send_data(php_http_env_response_t *r, const char *buf, size_t len)
{
- TSRMLS_FETCH_FROM_CTX(r->ts);
size_t chunk = r->throttle.chunk ? r->throttle.chunk : PHP_HTTP_SENDBUF_SIZE;
+ TSRMLS_FETCH_FROM_CTX(r->ts);
if (r->content.encoder) {
char *enc_str = NULL;
PHP_HTTP_API char *php_http_message_body_etag(php_http_message_body_t *body)
{
- TSRMLS_FETCH_FROM_CTX(body->ts);
const php_stream_statbuf *ssb = php_http_message_body_stat(body);
+ TSRMLS_FETCH_FROM_CTX(body->ts);
/* real file or temp buffer ? */
if (ssb && ssb->sb.st_mtime) {
PHP_HTTP_API void php_http_message_body_to_string(php_http_message_body_t *body, char **buf, size_t *len, off_t offset, size_t forlen)
{
- TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream *s = php_http_message_body_stream(body);
+ TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream_seek(s, offset, SEEK_SET);
if (!forlen) {
PHP_HTTP_API void php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *dst, off_t offset, size_t forlen)
{
- TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream *s = php_http_message_body_stream(body);
+ TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream_seek(s, offset, SEEK_SET);
if (!forlen) {
PHP_HTTP_API void php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen)
{
- TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream *s = php_http_message_body_stream(body);
char *buf = emalloc(0x1000);
+ TSRMLS_FETCH_FROM_CTX(body->ts);
php_stream_seek(s, offset, SEEK_SET);
PHP_HTTP_API STATUS php_http_message_body_add_form_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *path, php_stream *in)
{
- char *safe_name, *path_dup = estrdup(path);
+ char *safe_name, *path_dup = estrdup(path), *bname;
+ size_t bname_len;
TSRMLS_FETCH_FROM_CTX(body->ts);
safe_name = php_addslashes(estrdup(name), strlen(name), NULL, 1 TSRMLS_CC);
+
+ php_basename(path_dup, strlen(path_dup), NULL, 0, &bname, &bname_len TSRMLS_CC);
BOUNDARY_OPEN(body);
php_http_message_body_appendf(
"Content-Transfer-Encoding: binary" PHP_HTTP_CRLF
"Content-Type: %s" PHP_HTTP_CRLF
PHP_HTTP_CRLF,
- safe_name, basename(path_dup), ctype
+ safe_name, bname, ctype
);
php_stream_copy_to_stream_ex(in, php_http_message_body_stream(body), PHP_STREAM_COPY_ALL, NULL);
BOUNDARY_CLOSE(body);
o = ecalloc(1, sizeof(php_http_message_body_object_t));
zend_object_std_init((zend_object *) o, php_http_message_body_class_entry TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (ptr) {
*ptr = o;
PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, php_http_message_t **message)
{
- TSRMLS_FETCH_FROM_CTX(parser->ts);
char *str = NULL;
size_t len = 0;
size_t cut = 0;
+ TSRMLS_FETCH_FROM_CTX(parser->ts);
while (buffer->used || !php_http_message_parser_states[php_http_message_parser_state_is(parser)].need_data) {
#if 0
o = ecalloc(1, sizeof(php_http_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (ptr) {
*ptr = o;
static php_http_params_token_t def_arg_sep = {";", 1}, *def_arg_sep_ptr[] = {&def_arg_sep, NULL};
static php_http_params_token_t def_val_sep = {"=", 1}, *def_val_sep_ptr[] = {&def_val_sep, NULL};
static php_http_params_opts_t def_opts = {
- .param = def_param_sep_ptr,
- .arg = def_arg_sep_ptr,
- .val = def_val_sep_ptr,
- .defval = NULL,
- .flags = PHP_HTTP_PARAMS_DEFAULT
+ {{0},0},
+ def_param_sep_ptr,
+ def_arg_sep_ptr,
+ def_val_sep_ptr,
+ NULL,
+ PHP_HTTP_PARAMS_DEFAULT
};
PHP_HTTP_API php_http_params_opts_t *php_http_params_opts_default_get(php_http_params_opts_t *opts)
if (zend_hash_num_elements(Z_ARRVAL_P(arr))) {
zval_dtor(zv);
+#if PHP_VERSION_ID >= 50400
ZVAL_COPY_VALUE(zv, arr);
+#else
+ zv->value = arr->value;
+ Z_TYPE_P(zv) = Z_TYPE_P(arr);
+#endif
FREE_ZVAL(arr);
} else {
zval_ptr_dtor(&arr);
MAKE_STD_ZVAL(val);
if (opts->defval) {
+#if PHP_VERSION_ID >= 50400
ZVAL_COPY_VALUE(val, opts->defval);
+#else
+ val->value = opts->defval->value;
+ Z_TYPE_P(val) = Z_TYPE_P(opts->defval);
+#endif
zval_copy_ctor(val);
} else {
ZVAL_TRUE(val);
zcopy = php_http_ztyp(IS_STRING, zparams);
if (Z_STRLEN_P(zcopy)) {
php_http_params_opts_t opts = {
- .input = {
- .str = Z_STRVAL_P(zcopy),
- .len = Z_STRLEN_P(zcopy)
- },
- .param = php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC) TSRMLS_CC),
- .arg = php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC) TSRMLS_CC),
- .val = php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC) TSRMLS_CC),
- .flags = flags
+ {Z_STRVAL_P(zcopy), Z_STRLEN_P(zcopy)},
+ php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC) TSRMLS_CC),
+ php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC) TSRMLS_CC),
+ php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC) TSRMLS_CC),
+ NULL, flags
};
MAKE_STD_ZVAL(zparams);
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50339
+ zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init((zend_object *) o, ce);
+#endif
if (ptr) {
*ptr = o;