+--------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
+ | in the accomp395anying LICENSE file are met. |
+--------------------------------------------------------------------+
| Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
PHP_HTTP_API STATUS php_http_env_set_response_status_line(long code, php_http_version_t *v TSRMLS_DC)
{
- sapi_header_line h = {0};
+ sapi_header_line h = {NULL, 0, 0};
STATUS ret;
h.line_len = spprintf(&h.line, 0, "HTTP/%u.%u %ld %s", v->major, v->minor, code, php_http_env_get_response_status_for_code(code));
BOUNDARY_OPEN(body);
php_http_message_body_appendf(
body,
- "Content-Disposition: attachment; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF
+ "Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF
"Content-Transfer-Encoding: binary" PHP_HTTP_CRLF
"Content-Type: %s" PHP_HTTP_CRLF
PHP_HTTP_CRLF,
PHP_METHOD(HttpMessageBody, toCallback)
{
- struct fcd fcd = {0};
+ struct fcd fcd;
long offset = 0, forlen = 0;
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|ll", &fcd.fci, &fcd.fcc, &offset, &forlen)) {
PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_push(php_http_message_parser_t *parser, unsigned argc, ...)
{
+ php_http_message_parser_state_t state;
va_list va_args;
unsigned i;
- va_start(va_args, argc);
- php_http_message_parser_state_t state;
+ va_start(va_args, argc);
for (i = 0; i < argc; ++i) {
state = va_arg(va_args, php_http_message_parser_state_t);
zend_stack_push(&parser->stack, &state, sizeof(state));
}
}
- if (q && Z_DVAL_PP(q)) {
+ if (q && Z_DVAL_PP(q) > 0) {
Z_ADDREF_PP(q);
zend_hash_update(result, Z_STRVAL_P(supported), Z_STRLEN_P(supported) + 1, (void *) q, sizeof(zval *), NULL);
}
q = Z_DVAL_P(tmp);
zval_ptr_dtor(&tmp);
-
- if (0&&!q) {
- STR_FREE(key.str);
- continue;
- }
} else {
q = 1.0 - ++i / 100.0;
}
PHP_HTTP_API HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t *opts TSRMLS_DC)
{
- php_http_params_state_t state = {
- .input.str = opts->input.str,
- .input.len = opts->input.len,
- .param.str = NULL,
- .param.len = 0,
- .arg.str = NULL,
- .arg.len = 0,
- .val.str = NULL,
- .val.len = 0
- };
+ php_http_params_state_t state = {{NULL,0}, {NULL,0}, {NULL,0}, {NULL,0}, {NULL,NULL,NULL}};
+
+ state.input.str = opts->input.str;
+ state.input.len = opts->input.len;
if (!params) {
ALLOC_HASHTABLE(params);
zcopy = php_http_ztyp(IS_STRING, zparams);
if (Z_STRLEN_P(zcopy)) {
php_http_params_opts_t opts = {
- .input.str = Z_STRVAL_P(zcopy),
- .input.len = Z_STRLEN_P(zcopy),
+ .input = {
+ .str = Z_STRVAL_P(zcopy),
+ .len = Z_STRLEN_P(zcopy)
+ },
.param = parse_sep(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC) TSRMLS_CC),
.arg = parse_sep(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC) TSRMLS_CC),
.val = parse_sep(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC) TSRMLS_CC)
}
if (url) {
- php_url *tmp, qdu = {0};
+ php_url *tmp, qdu = {NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL};
zval *zurl = zend_read_property(php_http_request_class_entry, getThis(), ZEND_STRL("url"), 0 TSRMLS_CC);
zval *zqdata = zend_read_property(php_http_request_class_entry, getThis(), ZEND_STRL("queryData"), 0 TSRMLS_CC);
static int apply_pretty_key(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
+ zval **zpp = pDest, *arr = va_arg(args, zval *);
+
if (hash_key->arKey && hash_key->nKeyLength > 1) {
- /* FIXME: this seems evil */
- hash_key->h = zend_hash_func(php_http_pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength);
+ char *tmp = php_http_pretty_key(estrndup(hash_key->arKey, hash_key->nKeyLength - 1), hash_key->nKeyLength - 1, 1, 0);
+
+ Z_ADDREF_PP(zpp);
+ add_assoc_zval_ex(arr, tmp, hash_key->nKeyLength, *zpp);
+ efree(tmp);
}
return ZEND_HASH_APPLY_KEEP;
}
}
} else if (opts) {
if (prettify_keys) {
- zend_hash_apply_with_arguments(Z_ARRVAL_P(opts) TSRMLS_CC, apply_pretty_key, 0, NULL);
+ zval *tmp;
+
+ MAKE_STD_ZVAL(tmp);
+ array_init_size(tmp, zend_hash_num_elements(Z_ARRVAL_P(opts)));
+ zend_hash_apply_with_arguments(Z_ARRVAL_P(opts) TSRMLS_CC, apply_pretty_key, 1, tmp);
+ opts = tmp;
+ } else {
+ Z_ADDREF_P(opts);
}
- Z_ADDREF_P(opts);
add_assoc_zval_ex(new_opts, key, len, opts);
}
zend_update_property(php_http_request_class_entry, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC);
timeout_val.tv_sec = (time_t) timeout;
timeout_val.tv_usec = PHP_HTTP_USEC(timeout) % PHP_HTTP_MCROSEC;
- RETURN_SUCCESS(php_http_request_pool_wait(obj->pool, timeout ? &timeout_val : NULL));
+ RETURN_SUCCESS(php_http_request_pool_wait(obj->pool, timeout > 0 ? &timeout_val : NULL));
}
RETURN_FALSE;
}
"\r\n".
"fuz\r\n".
"--%x.%x\r\n".
- "Content-Disposition: attachment; name=\"upload\"; filename=\"MessageBodyTest.php\"\r\n".
+ "Content-Disposition: form-data; name=\"upload\"; filename=\"MessageBodyTest.php\"\r\n".
"Content-Transfer-Encoding: binary\r\n".
"Content-Type: text/plain\r\n".
"\r\n".