diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 12a27c78f9f..dec44c68575 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1358,7 +1358,7 @@ PHP_METHOD(SoapServer, handle) sdlPtr old_sdl = NULL; soapServicePtr service; xmlDocPtr doc_request=NULL, doc_return; - zval function_name, **params, **raw_post, *soap_obj, retval, **server_vars; + zval function_name, **params, **raw_post, *soap_obj, retval; char *fn_name, cont_len[30]; int num_params = 0, size, i, call_status = 0; xmlChar *buf; @@ -1380,54 +1380,51 @@ PHP_METHOD(SoapServer, handle) } INIT_ZVAL(retval); - if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server_vars) == SUCCESS) { - zval **req_method, **query_string; - if (zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_METHOD", sizeof("REQUEST_METHOD"), (void **)&req_method) == SUCCESS) { - if (!strcmp(Z_STRVAL_PP(req_method), "GET") && zend_hash_find(Z_ARRVAL_PP(server_vars), "QUERY_STRING", sizeof("QUERY_STRING"), (void **)&query_string) == SUCCESS) { - if (stricmp(Z_STRVAL_PP(query_string), "wsdl") == 0) { - if (service->sdl) { + if (SG(request_info).request_method && + strcmp(SG(request_info).request_method, "GET") == 0 && + SG(request_info).query_string && + stricmp(SG(request_info).query_string, "wsdl") == 0) { + + if (service->sdl) { /* - char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source)); - strcpy(hdr,"Location: "); - strcat(hdr,service->sdl->source); - sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1); - efree(hdr); + char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source)); + strcpy(hdr,"Location: "); + strcat(hdr,service->sdl->source); + sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1); + efree(hdr); */ - zval readfile, readfile_ret, *param; + zval readfile, readfile_ret, *param; - INIT_ZVAL(readfile); - INIT_ZVAL(readfile_ret); - MAKE_STD_ZVAL(param); + INIT_ZVAL(readfile); + INIT_ZVAL(readfile_ret); + MAKE_STD_ZVAL(param); - sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1); - ZVAL_STRING(param, service->sdl->source, 1); - ZVAL_STRING(&readfile, "readfile", 1); - if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m TSRMLS_CC) == FAILURE) { - soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL TSRMLS_CC); - } - - zval_ptr_dtor(¶m); - zval_dtor(&readfile); - zval_dtor(&readfile_ret); - - SOAP_SERVER_END_CODE(); - return; - } else { - soap_server_fault("Server", "WSDL generation is not supported yet", NULL, NULL, NULL TSRMLS_CC); -/* - sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1); - PUTS("\nuri); - PUTS("\">\n"); - PUTS(""); -*/ - SOAP_SERVER_END_CODE(); - return; - } - } + sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1); + ZVAL_STRING(param, service->sdl->source, 1); + ZVAL_STRING(&readfile, "readfile", 1); + if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m TSRMLS_CC) == FAILURE) { + soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL TSRMLS_CC); } + + zval_ptr_dtor(¶m); + zval_dtor(&readfile); + zval_dtor(&readfile_ret); + + SOAP_SERVER_END_CODE(); + return; + } else { + soap_server_fault("Server", "WSDL generation is not supported yet", NULL, NULL, NULL TSRMLS_CC); +/* + sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1); + PUTS("\nuri); + PUTS("\">\n"); + PUTS(""); +*/ + SOAP_SERVER_END_CODE(); + return; } } @@ -1440,6 +1437,7 @@ PHP_METHOD(SoapServer, handle) && ((*raw_post)->type==IS_STRING)) { zval **server_vars, **encoding; + zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS && Z_TYPE_PP(server_vars) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING"), (void **) &encoding)==SUCCESS && @@ -1476,14 +1474,10 @@ PHP_METHOD(SoapServer, handle) doc_request = soap_xmlParseMemory(Z_STRVAL_PP(raw_post),Z_STRLEN_PP(raw_post)); } } else { - if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server_vars) == SUCCESS) { - zval **req_method; - if (zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_METHOD", sizeof("REQUEST_METHOD"), (void **)&req_method) == SUCCESS) { - if (!strcmp(Z_STRVAL_PP(req_method), "POST")) { - if (!zend_ini_long("always_populate_raw_post_data", sizeof("always_populate_raw_post_data"), 0)) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "PHP-SOAP requires 'always_populate_raw_post_data' to be on please check your php.ini file"); - } - } + if (SG(request_info).request_method && + strcmp(SG(request_info).request_method, "POST") == 0) { + if (!zend_ini_long("always_populate_raw_post_data", sizeof("always_populate_raw_post_data"), 0)) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "PHP-SOAP requires 'always_populate_raw_post_data' to be on please check your php.ini file"); } } soap_server_fault("Server", "Bad Request. Can't find HTTP_RAW_POST_DATA", NULL, NULL, NULL TSRMLS_CC);