- with_error_handling(EH_THROW, php_http_exception_class_entry) {
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!b", &zmessage, &greedy) && zmessage) {
- if (Z_TYPE_P(zmessage) == IS_RESOURCE) {
- php_stream *s;
- php_http_message_parser_t p;
-
- php_stream_from_zval(s, &zmessage);
- if (s && php_http_message_parser_init(&p TSRMLS_CC)) {
- unsigned flags = (greedy ? PHP_HTTP_MESSAGE_PARSER_GREEDY : 0);
-
- php_http_message_parser_parse_stream(&p, s, flags, &msg);
- php_http_message_parser_dtor(&p);
- }
-
- if (!msg) {
- php_http_error(HE_THROW, PHP_HTTP_E_MESSAGE, "could not parse message from stream");
- }
- } else {
- zmessage = php_http_ztyp(IS_STRING, zmessage);
- if (!(msg = php_http_message_parse(NULL, Z_STRVAL_P(zmessage), Z_STRLEN_P(zmessage), greedy TSRMLS_CC))) {
- php_http_error(HE_THROW, PHP_HTTP_E_MESSAGE, "could not parse message: %.*s", MIN(25, Z_STRLEN_P(zmessage)), Z_STRVAL_P(zmessage));
- }
- zval_ptr_dtor(&zmessage);
- }
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!b", &zmessage, &greedy), invalid_arg, return);