Issues I don't know how to solve yet are as follows:
-There are random segfaults with PHP-5.1 and HttpRequestPool.
PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, [$ext_shared])
PHP_SUBST([HTTP_SHARED_LIBADD])
PHP_ADD_MAKEFILE_FRAGMENT
+ if ! test -z "$HTTP_ODD_WARNINGS"; then
+ CFLAGS=" -g -O2 -W -Wchar-subscripts -Wformat=2 -Wno-format-y2k -Wimplicit -Wmissing-braces -Wunused-variable -Wbad-function-cast -Wpointer-arith -Wsign-compare -Winline"
+ PHP_SUBST([CFLAGS])
+ fi
AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
fi
static int check_tzone(char *tzone)
{
- int i;
+ unsigned i;
const struct time_zone *check = time_zones;
for (i = 0; i < sizeof(time_zones) / sizeof(time_zones[0]); i++) {
if (!strcmp(tzone, check->name)) {
enum assume_next dignext = DATE_MDAY;
const char *indate = date;
- int found = 0, part = 0; /* max 6 parts */
+ int part = 0; /* max 6 parts */
while (*date && (part < 6)) {
int found = 0;
{
char *header, *value;
int header_len, value_len;
- zend_bool match_case = 0, result = 0;
+ zend_bool match_case = 0;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &header, &header_len, &value, &value_len, &match_case)) {
RETURN_FALSE;
} else {
qual = 1000.0 - i++;
}
+ /* TODO: support primaries only, too */
FOREACH_HASH_VAL((HashTable *)supported, zsupp) {
if (!strcasecmp(Z_STRVAL_PP(zsupp), Z_STRVAL_PP(zentry))) {
add_assoc_double(&zentries, Z_STRVAL_PP(zsupp), qual);
range = Z_STRVAL_P(zrange);
if (strncmp(range, "bytes=", sizeof("bytes=") - 1)) {
+ /* should we really issue a notice for a client misbehaviour?
http_error(E_NOTICE, HTTP_E_HEADER, "Range header misses bytes=");
+ */
return RANGE_NO;
}
return RANGE_NO;
}
/* "0-0" or overflow */
- if (end == -10 || length <= end) {
+ if (end == -10 || length <= (size_t) end) {
return RANGE_ERR;
}
begin = 0;
/* "-12345" */
case -1:
/* "-", "-0" or overflow */
- if (end == -1 || end == -10 || length <= end) {
+ if (end == -1 || end == -10 || length <= (size_t) end) {
return RANGE_ERR;
}
begin = length - end;
/* "12345-" */
case -1:
- if (length <= begin) {
+ if (length <= (size_t) begin) {
return RANGE_ERR;
}
end = length - 1;
/* "12345-67890" */
default:
- if ( (length <= begin) ||
- (length <= end) ||
+ if ( (length <= (size_t) begin) ||
+ (length <= (size_t) end) ||
(end < begin)) {
return RANGE_ERR;
}
line = header;
- while (header_len >= (line - begin)) {
+ while (header_len >= (size_t) (line - begin)) {
int value_len = 0;
switch (*line++)
zval *len;
char *tmp;
- spprintf(&tmp, 0, "%lu", decoded_len);
+ spprintf(&tmp, 0, "%lu", (ulong) decoded_len);
MAKE_STD_ZVAL(len);
ZVAL_STRING(len, tmp, 0);
ALLOC_HASHTABLE(OBJ_PROP(o));
zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_message_object_free, NULL TSRMLS_CC);
+ ov.handle = putObject(http_message_object, o);
ov.handlers = &http_message_object_handlers;
return ov;
{
case HTTP_MSG_PROPHASH_TYPE:
convert_to_long_ex(&value);
- if (Z_LVAL_P(value) != msg->type) {
+ if ((http_message_type) Z_LVAL_P(value) != msg->type) {
if (HTTP_MSG_TYPE(REQUEST, msg)) {
if (msg->info.request.method) {
efree(msg->info.request.method);
case IS_DOUBLE: convert_to_double_ex(zoption); break;
case IS_STRING: convert_to_string_ex(zoption); break;
case IS_ARRAY: convert_to_array_ex(zoption); break;
- case IS_OBJECT: convert_to_object_ex(zoption); break;
+ case IS_OBJECT: convert_to_object_ex(zoption); break;
default:
break;
}
zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_request_object_free, NULL TSRMLS_CC);
+ ov.handle = putObject(http_request_object, o);
ov.handlers = &http_request_object_handlers;
return ov;
PHP_METHOD(HttpRequest, send)
{
STATUS status = FAILURE;
- http_request_body body = {0};
+ http_request_body body = {0, NULL, 0};
getObject(http_request_object, obj);
NO_ARGS;
http_error_ex(E_WARNING, HTTP_E_CURL, "HttpRequest object(#%d) is already member of %s HttpRequestPool", Z_OBJ_HANDLE_P(request), req->pool == pool ? "this" : "another");
} else {
http_request_body *body = http_request_body_new();
- zval *info = GET_PROP_EX(req, request, responseInfo);
if (SUCCESS != http_request_object_requesthandler(req, request, body)) {
http_error_ex(E_WARNING, HTTP_E_CURL, "Could not initialize HttpRequest object for attaching to the HttpRequestPool");
zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_requestpool_object_free, NULL TSRMLS_CC);
+ ov.handle = putObject(http_requestpool_object, o);
ov.handlers = &http_requestpool_object_handlers;
return ov;
http_send_status(206);
/* send content range header */
- snprintf(range_header, 255, "Content-Range: bytes %d-%d/%d", **begin, **end, size);
+ snprintf(range_header, 255, "Content-Range: bytes %ld-%ld/%lu", **begin, **end, (ulong) size);
http_send_header(range_header);
/* send requested chunk */
http_send_status(206);
/* send multipart/byteranges header */
- snprintf(bound, 22, "--%d%0.9f", time(NULL), php_combined_lcg(TSRMLS_C));
+ snprintf(bound, 22, "--%lu%0.9f", (ulong) time(NULL), php_combined_lcg(TSRMLS_C));
strncat(multi_header, bound + 2, 21);
http_send_header(multi_header);
snprintf(preface, 1023,
HTTP_CRLF "%s"
HTTP_CRLF "Content-Type: %s"
- HTTP_CRLF "Content-Range: bytes %ld-%ld/%ld"
+ HTTP_CRLF "Content-Range: bytes %ld-%ld/%lu"
HTTP_CRLF
HTTP_CRLF,
HTTP_G(send).content_type ? HTTP_G(send).content_type : "application/x-octetstream",
**begin,
**end,
- size
+ (ulong) size
);
PHPWRITE(preface, strlen(preface));
#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
struct servent *se;
#endif
- php_url *purl, furl = {NULL};
+ php_url *purl = NULL, furl;
size_t full_len = 0;
zval *zhost = NULL;
char *scheme = NULL, *uri, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1);
# define getObject(t, o) getObjectEx(t, o, getThis())
# define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC))
+# define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) t## _free, NULL TSRMLS_CC);
# define OBJ_PROP(o) (o)->zo.properties
# define DCL_STATIC_PROP(a, t, n, v) zend_declare_property_ ##t(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
# define DCL_STATIC_PROP_Z(a, n, v) zend_declare_property(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)