static inline unsigned long realpath_cache_key(const char *path, int path_len)
{
- register unsigned long h;
-
- const char *e = path + path_len;
- for (h = 2166136261U; path < e; ) {
- h *= 16777619;
- h ^= *path++;
- }
- return h;
+ register unsigned long h;
+ const char *e = path + path_len;
+
+ for (h = 2166136261U; path < e;) {
+ h *= 16777619;
+ h ^= *path++;
+ }
+
+ return h;
}
CWD_API void realpath_cache_clean(TSRMLS_D)
n = bucket->key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
bucket->next = CWDG(realpath_cache)[n];
CWDG(realpath_cache)[n] = bucket;
- CWDG(realpath_cache_size) += size;
+ CWDG(realpath_cache_size) += size;
}
}
}
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
- spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
- if (content_type && SUCCESS == sapi_add_header(content_type, strlen(content_type), 0)) {
+ int len = spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
+ if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
SG(sapi_headers).send_default_content_type = 0;
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
}
char *protocol_version = NULL;
int protocol_version_len = 3; /* Default: "1.0" */
char *charset = NULL;
+ struct timeval timeout;
tmp_line[0] = '\0';
if (redirect_max < 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Redirection limit reached, aborting");
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Redirection limit reached, aborting");
return NULL;
}
}
}
+ if (context && php_stream_context_get_option(context, wrapper->wops->label, "timeout", &tmpzval) == SUCCESS) {
+ SEPARATE_ZVAL(tmpzval);
+ convert_to_double_ex(tmpzval);
+ timeout.tv_sec = (time_t) Z_DVAL_PP(tmpzval);
+ timeout.tv_usec = (size_t) ((Z_DVAL_PP(tmpzval) - timeout.tv_sec) * 1000000);
+ } else {
+ timeout.tv_sec = FG(default_socket_timeout);
+ timeout.tv_usec = 0;
+ }
+
stream = php_stream_xport_create(transport_string, transport_len, options,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
- NULL, NULL, context, &errstr, NULL);
+ NULL, &timeout, context, &errstr, NULL);
+
+ if (stream) {
+ php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &timeout);
+ }
if (errstr) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", errstr);
redirect_max = Z_LVAL_PP(tmpzval);
}
- if (header_init && context &&
- php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
+ if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval);
scratch = emalloc(scratch_len);
strcat(scratch, " ");
}
}
-
- if (context &&
- php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) {
+
+ if (context && php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) {
SEPARATE_ZVAL(tmpzval);
convert_to_double_ex(tmpzval);
protocol_version_len = spprintf(&protocol_version, 0, "%.1F", Z_DVAL_PP(tmpzval));
}
}
- if (!reqok || location[0] != '\0') {
+ if (!reqok || location[0] != '\0') {
+ if (options & STREAM_ONLY_GET_HEADERS && redirect_max <= 1) {
+ goto out;
+ }
+
if (location[0] != '\0')
php_stream_notify_info(context, PHP_STREAM_NOTIFY_REDIRECTED, location, 0);
static char *url_attr_addon(const char *tag,const char *attr,const char *val,const char *buf)
{
int flag = 0;
- TSRMLS_FETCH();
- if(!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
+ if (!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
flag = 1;
- } else if(!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) {
+ } else if (!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) {
flag = 1;
- } else if(!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
+ } else if (!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
flag = 1;
- } else if(!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
+ } else if (!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
flag = 1;
- } else if(!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) {
+ } else if (!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) {
flag = 1;
}
- if(flag) {
- if(!strstr(val,buf)&&!strchr(val,':'))
- {
- char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1);
- int n;
+ if(flag && !strstr(val,buf) && !strchr(val,':')) {
+ char *result;
+ TSRMLS_FETCH();
- if(strchr(val,'?')) {
- strcpy(result,PG(arg_separator).output);
- n=strlen(PG(arg_separator).output);
- } else {
- *result='?';
- n=1;
- }
- strcpy(result+n,buf);
- return result;
- }
+ spprintf(&result, 0, "%s%s", (strchr(val,'?') ? PG(arg_separator).output : "?"), buf);
+ return result;
}
return NULL;
}
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp, p, maxl);
outp+=l;
*newlen+=l;
efree(p);
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);
maxl+=l;
out=realloc(out,maxl);
outp=out+*newlen;
- strcpy(outp,p);
+ strlcpy(outp,p,maxl);
outp+=l;
*newlen+=l;
efree(p);
*/
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
{
- char *data = NULL;
- int length = 0;
+ char *data;
+ int length;
/* $HTTP_RAW_POST_DATA registration */
- if(!strcmp(SG(request_info).request_method, "POST")) {
- if(NULL == SG(request_info).post_entry) {
+ if (!strcmp(SG(request_info).request_method, "POST")) {
+ if (NULL == SG(request_info).post_entry) {
/* no post handler registered, so we just swallow the data */
sapi_read_standard_form_data(TSRMLS_C);
+ }
+
+ /* For unknown content types we create HTTP_RAW_POST_DATA even if always_populate_raw_post_data off,
+ * this is in-effecient, but we need to keep doing it for BC reasons (for now) */
+ if ((PG(always_populate_raw_post_data) || NULL == SG(request_info).post_entry) && SG(request_info).post_data) {
length = SG(request_info).post_data_length;
data = estrndup(SG(request_info).post_data, length);
- } else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
- length = SG(request_info).post_data_length;
- data = estrndup(SG(request_info).post_data, length);
- }
- if(data) {
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
}
}
in the long run post handlers should be changed to not touch
request_info.post_data for memory preservation reasons
*/
- if(SG(request_info).post_data) {
+ if (SG(request_info).post_data) {
SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
SG(request_info).raw_post_data_length = SG(request_info).post_data_length;
}
-
}
/* }}} */
} elseif (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
$post = trim($section_text['POST']);
+
+ if (array_key_exists('GZIP_POST', $section_text) && function_exists('gzencode')) {
+ $post = gzencode($post, 9, FORCE_GZIP);
+ $env['HTTP_CONTENT_ENCODING'] = 'gzip';
+ } else if (array_key_exists('DEFLATE_POST', $section_text) && function_exists('gzcompress')) {
+ $post = gzcompress($post, 9);
+ $env['HTTP_CONTENT_ENCODING'] = 'deflate';
+ }
+
save_text($tmp_post, $post);
$content_length = strlen($post);