HTTP message API (#19)

* HTTP message API

* Added MacOS CI

* Grabbed fixes for mac from aws-crt-ffi
This commit is contained in:
Justin Boswell
2021-03-25 13:14:07 -04:00
committed by GitHub
parent 974fe3d74a
commit 9c9422c21f
14 changed files with 421 additions and 69 deletions
+6
View File
@@ -38,6 +38,12 @@ function aws_crt_input_stream_eof(int $stream): bool {}
function aws_crt_input_stream_get_length(int $stream): int {}
function aws_crt_http_message_new_from_blob(string $blob): int {}
function aws_crt_http_message_to_blob(int $message): string {}
function aws_crt_http_message_release(int $message): void {}
function aws_crt_credentials_options_new(): object {}
function aws_crt_credentials_options_release(object $options): void {}
+19 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 5549e1214a9a419075f5cb561adb2d7a340c5916 */
* Stub hash: bd274f6b280b27aa5fb7d3be2ce85ad065936943 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_last_error, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -68,6 +68,18 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_input_stream_get_length,
ZEND_ARG_TYPE_INFO(0, stream, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_http_message_new_from_blob, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, blob, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_http_message_to_blob, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, message, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_http_message_release, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, message, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_aws_crt_credentials_options_new arginfo_aws_crt_input_stream_options_new
#define arginfo_aws_crt_credentials_options_release arginfo_aws_crt_input_stream_options_release
@@ -133,6 +145,9 @@ ZEND_FUNCTION(aws_crt_input_stream_seek);
ZEND_FUNCTION(aws_crt_input_stream_read);
ZEND_FUNCTION(aws_crt_input_stream_eof);
ZEND_FUNCTION(aws_crt_input_stream_get_length);
ZEND_FUNCTION(aws_crt_http_message_new_from_blob);
ZEND_FUNCTION(aws_crt_http_message_to_blob);
ZEND_FUNCTION(aws_crt_http_message_release);
ZEND_FUNCTION(aws_crt_credentials_options_new);
ZEND_FUNCTION(aws_crt_credentials_options_release);
ZEND_FUNCTION(aws_crt_credentials_options_set_access_key_id);
@@ -169,6 +184,9 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(aws_crt_input_stream_read, arginfo_aws_crt_input_stream_read)
ZEND_FE(aws_crt_input_stream_eof, arginfo_aws_crt_input_stream_eof)
ZEND_FE(aws_crt_input_stream_get_length, arginfo_aws_crt_input_stream_get_length)
ZEND_FE(aws_crt_http_message_new_from_blob, arginfo_aws_crt_http_message_new_from_blob)
ZEND_FE(aws_crt_http_message_to_blob, arginfo_aws_crt_http_message_to_blob)
ZEND_FE(aws_crt_http_message_release, arginfo_aws_crt_http_message_release)
ZEND_FE(aws_crt_credentials_options_new, arginfo_aws_crt_credentials_options_new)
ZEND_FE(aws_crt_credentials_options_release, arginfo_aws_crt_credentials_options_release)
ZEND_FE(aws_crt_credentials_options_set_access_key_id, arginfo_aws_crt_credentials_options_set_access_key_id)
+73 -39
View File
@@ -61,7 +61,7 @@ PHP_FUNCTION(aws_crt_last_error) {
PHP_FUNCTION(aws_crt_error_str) {
zend_ulong error_code = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
RETURN_NULL();
}
@@ -72,7 +72,7 @@ PHP_FUNCTION(aws_crt_error_str) {
PHP_FUNCTION(aws_crt_error_name) {
zend_ulong error_code = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
RETURN_NULL();
}
@@ -83,7 +83,7 @@ PHP_FUNCTION(aws_crt_error_name) {
PHP_FUNCTION(aws_crt_error_debug_str) {
zend_ulong error_code = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
RETURN_NULL();
}
@@ -98,7 +98,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_new) {
PHP_FUNCTION(aws_crt_event_loop_group_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
return;
}
@@ -110,7 +110,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_set_max_threads) {
zend_ulong php_options = 0;
zend_ulong num_threads = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_options, &num_threads) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_options, &num_threads) == FAILURE) {
RETURN_NULL();
}
@@ -121,7 +121,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_set_max_threads) {
PHP_FUNCTION(aws_crt_event_loop_group_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
@@ -133,7 +133,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_new) {
PHP_FUNCTION(aws_crt_event_loop_group_release) {
zend_ulong php_elg = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_elg) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_elg) == FAILURE) {
return;
}
@@ -153,7 +153,7 @@ PHP_FUNCTION(aws_crt_input_stream_options_new) {
PHP_FUNCTION(aws_crt_input_stream_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
return;
}
@@ -170,7 +170,7 @@ PHP_FUNCTION(aws_crt_input_stream_options_set_user_data) {
zend_ulong php_options = 0;
zval *user_data = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &php_options, &user_data) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &php_options, &user_data) == FAILURE) {
return;
}
@@ -187,7 +187,7 @@ static int s_php_stream_seek(void *user_data, int64_t offset, aws_crt_input_stre
static int s_php_stream_read(void *user_data, uint8_t *dest, size_t dest_length) {
php_stream *stream = user_data;
return php_stream_read(stream, dest, dest_length) != 0;
return php_stream_read(stream, (char *)dest, dest_length) != 0;
}
static int s_php_stream_get_length(void *user_data, int64_t *out_length) {
@@ -204,7 +204,8 @@ static int s_php_stream_get_status(void *user_data, aws_crt_input_stream_status
out_status->is_valid = stream != NULL;
/* We would like to use php_stream_eof here, but certain streams (notably php://memory)
* are not actually capable of EOF, so we get to do it the hard way */
size_t length = 0, pos = 0;
int64_t length = 0;
int64_t pos = 0;
s_php_stream_get_length(stream, &length);
pos = php_stream_tell(stream);
out_status->is_end_of_stream = pos == length;
@@ -219,7 +220,7 @@ static void s_php_stream_destroy(void *user_data) {
PHP_FUNCTION(aws_crt_input_stream_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
@@ -236,7 +237,7 @@ PHP_FUNCTION(aws_crt_input_stream_new) {
PHP_FUNCTION(aws_crt_input_stream_release) {
zend_ulong php_stream = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
RETURN_NULL();
}
@@ -249,7 +250,7 @@ PHP_FUNCTION(aws_crt_input_stream_seek) {
zend_ulong offset = 0;
zend_ulong basis = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &php_stream, &offset, &basis) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &php_stream, &offset, &basis) == FAILURE) {
RETURN_NULL();
}
@@ -261,21 +262,21 @@ PHP_FUNCTION(aws_crt_input_stream_read) {
zend_ulong php_stream = 0;
zend_ulong length = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_stream, &length) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_stream, &length) == FAILURE) {
RETURN_NULL();
}
aws_crt_input_stream *stream = (void *)php_stream;
uint8_t *buf = emalloc(length);
int ret = aws_crt_input_stream_read(stream, buf, length);
AWS_RETURN_STRINGL(buf, length);
AWS_RETURN_STRINGL((const char *)buf, length);
efree(buf);
}
PHP_FUNCTION(aws_crt_input_stream_eof) {
zend_ulong php_stream = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
RETURN_NULL();
}
@@ -288,16 +289,54 @@ PHP_FUNCTION(aws_crt_input_stream_eof) {
PHP_FUNCTION(aws_crt_input_stream_get_length) {
zend_ulong php_stream = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
RETURN_NULL();
}
aws_crt_input_stream *stream = (void *)php_stream;
size_t length = 0;
int64_t length = 0;
aws_crt_input_stream_get_length(stream, &length);
RETURN_LONG(length);
}
PHP_FUNCTION(aws_crt_http_message_new_from_blob) {
const char *blob = NULL;
size_t blob_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &blob, &blob_len) == FAILURE) {
RETURN_NULL();
}
aws_crt_http_message *message = aws_crt_http_message_new_from_blob((uint8_t *)blob, blob_len);
RETURN_LONG((zend_ulong)message);
}
PHP_FUNCTION(aws_crt_http_message_to_blob) {
zend_ulong php_msg = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_msg) == FAILURE) {
RETURN_NULL();
}
aws_crt_http_message *message = (void *)php_msg;
uint8_t *blob = NULL;
size_t blob_len = 0;
aws_crt_http_message_to_blob(message, &blob, &blob_len);
AWS_RETURN_STRINGL((const char *)blob, blob_len);
aws_crt_mem_release(blob);
}
PHP_FUNCTION(aws_crt_http_message_release) {
zend_ulong php_msg = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_msg) == FAILURE) {
RETURN_NULL();
}
aws_crt_http_message *message = (void *)php_msg;
aws_crt_http_message_release(message);
}
PHP_FUNCTION(aws_crt_credentials_options_new) {
aws_crt_credentials_options *options = aws_crt_credentials_options_new();
RETURN_LONG((zend_ulong)options);
@@ -306,7 +345,7 @@ PHP_FUNCTION(aws_crt_credentials_options_new) {
PHP_FUNCTION(aws_crt_credentials_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
@@ -319,8 +358,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_access_key_id) {
const char *access_key_id = NULL;
size_t access_key_id_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &access_key_id, &access_key_id_len) == FAILURE) {
RETURN_NULL();
}
@@ -333,8 +371,8 @@ PHP_FUNCTION(aws_crt_credentials_options_set_secret_access_key) {
const char *secret_access_key = NULL;
size_t secret_access_key_len = 0;
if (zend_parse_parameters(
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
FAILURE) {
RETURN_NULL();
}
@@ -347,8 +385,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
const char *session_token = NULL;
size_t session_token_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &session_token, &session_token_len) == FAILURE) {
RETURN_NULL();
}
@@ -359,8 +396,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
zend_ulong php_options = 0;
zend_ulong expiration_timepoint_seconds = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_options, &expiration_timepoint_seconds) ==
FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_options, &expiration_timepoint_seconds) == FAILURE) {
RETURN_NULL();
}
@@ -371,7 +407,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
PHP_FUNCTION(aws_crt_credentials_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
@@ -383,7 +419,7 @@ PHP_FUNCTION(aws_crt_credentials_new) {
PHP_FUNCTION(aws_crt_credentials_release) {
zend_ulong php_credentials = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_credentials) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_credentials) == FAILURE) {
RETURN_NULL();
}
@@ -394,7 +430,7 @@ PHP_FUNCTION(aws_crt_credentials_release) {
PHP_FUNCTION(aws_crt_credentials_provider_release) {
zend_ulong php_creds_provider = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_creds_provider) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_creds_provider) == FAILURE) {
RETURN_NULL();
}
@@ -410,7 +446,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_new) {
PHP_FUNCTION(aws_crt_credentials_provider_static_options_release) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
@@ -423,8 +459,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id) {
const char *access_key_id = NULL;
size_t access_key_id_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &access_key_id, &access_key_id_len) == FAILURE) {
RETURN_NULL();
}
@@ -437,8 +472,8 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key)
const char *secret_access_key = NULL;
size_t secret_access_key_len = 0;
if (zend_parse_parameters(
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
FAILURE) {
RETURN_NULL();
}
@@ -452,8 +487,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
const char *session_token = NULL;
size_t session_token_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &session_token, &session_token_len) == FAILURE) {
RETURN_NULL();
}
@@ -464,7 +498,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
PHP_FUNCTION(aws_crt_credentials_provider_static_new) {
zend_ulong php_options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
RETURN_NULL();
}
+1 -1
View File
@@ -19,7 +19,7 @@
# error "PHP >= 5.6 is required"
#endif
#define AWS_PHP_AT_LEAST_7 defined(ZEND_EXTENSION_API_NO_7_0_X) || (ZEND_EXTENSION_API_NO >= 320151012)
#define AWS_PHP_AT_LEAST_7 (ZEND_EXTENSION_API_NO >= 320151012)
ZEND_BEGIN_MODULE_GLOBALS(awscrt)
long log_level;