Skip to content

Commit 82ddb23

Browse files
committed
Loosen restrictions on method used with http_fopen_wrapper, still default to GET though.
1 parent d75d52a commit 82ddb23

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,19 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
164164

165165
php_stream_notify_info(context, PHP_STREAM_NOTIFY_CONNECT, NULL, 0);
166166

167-
scratch_len = strlen(path) + 32;
168-
scratch = emalloc(scratch_len);
169-
170167
if (context &&
171-
php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS &&
172-
Z_STRLEN_PP(tmpzval) > 0 &&
173-
strncasecmp(Z_STRVAL_PP(tmpzval), "POST", Z_STRLEN_PP(tmpzval)) == 0) {
174-
strcpy(scratch, "POST ");
175-
} else {
168+
php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
169+
if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
170+
scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval);
171+
scratch = emalloc(scratch_len);
172+
strlcpy(scratch, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) + 1);
173+
strcat(scratch, " ");
174+
}
175+
}
176+
177+
if (!scratch) {
178+
scratch_len = strlen(path) + 32;
179+
scratch = emalloc(scratch_len);
176180
strcpy(scratch, "GET ");
177181
}
178182

0 commit comments

Comments
 (0)