|
@@ -38,6 +38,7 @@ const zend_function_entry fcgi_functions[] = {
|
|
|
PHP_FE(fcgi_finish, NULL)
|
|
|
PHP_FE(fcgi_getparam, NULL)
|
|
|
PHP_FE(fcgi_echo, NULL)
|
|
|
+ PHP_FE(fcgi_getcontent, NULL)
|
|
|
PHP_FE_END /* Must be the last line in fcgi_functions[] */
|
|
|
};
|
|
|
|
|
@@ -150,12 +151,42 @@ PHP_FUNCTION(fcgi_getparam)
|
|
|
}
|
|
|
|
|
|
const char* ret = FCGX_GetParam(arg, stParams);
|
|
|
- ret == NULL ? "" : ret;
|
|
|
+ ret = (ret == NULL) ? "" : ret;
|
|
|
|
|
|
char* result = estrdup(ret);
|
|
|
RETURN_STRINGL(result,strlen(result),0);
|
|
|
}
|
|
|
|
|
|
+static int content_length()
|
|
|
+{
|
|
|
+ const char* pbuf = FCGX_GetParam("CONTENT_LENGTH", stParams);
|
|
|
+ if(pbuf)
|
|
|
+ {
|
|
|
+ if(strlen(pbuf) == 0)
|
|
|
+ return 0;
|
|
|
+ else
|
|
|
+ return atoi(pbuf);
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+PHP_FUNCTION(fcgi_getcontent)
|
|
|
+{
|
|
|
+ int con_len = content_length();
|
|
|
+ if(con_len) {
|
|
|
+ char* pCon = (char*)malloc(con_len + 1);
|
|
|
+ con_len = FCGX_GetStr(pCon, con_len, stInstream);
|
|
|
+ pCon[con_len] = '\0';
|
|
|
+
|
|
|
+ char* result = estrdup(pCon);
|
|
|
+ RETURN_STRINGL(result,strlen(result),0);
|
|
|
+ } else {
|
|
|
+ char* result = estrdup("");
|
|
|
+ RETURN_STRINGL(result,strlen(result),0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
PHP_FUNCTION(fcgi_echo)
|
|
|
{
|
|
|
char *arg = NULL;
|