#define HTTP_WRAPPER_HEADER_INIT 1
#define HTTP_WRAPPER_REDIRECTED 2
- php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
- char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
+ static inline void strip_header(char *header_bag, char *lc_header_bag,
+ const char *lc_header_name)
+ {
+ char *lc_header_start = strstr(lc_header_bag, lc_header_name);
+ char *header_start = header_bag + (lc_header_start - lc_header_bag);
+
+ if (lc_header_start
+ && (lc_header_start == lc_header_bag || *(lc_header_start-1) == '\n')
+ ) {
+ char *lc_eol = strchr(lc_header_start, '\n');
+ char *eol = header_start + (lc_eol - lc_header_start);
+
+ if (lc_eol) {
+ size_t eollen = strlen(lc_eol);
+
+ memmove(lc_header_start, lc_eol+1, eollen);
+ memmove(header_start, eol+1, eollen);
+ } else {
+ *lc_header_start = '\0';
+ *header_start = '\0';
+ }
+ }
+ }
+
-php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
++php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
++ const char *path, const char *mode, int options, char **opened_path,
++ php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
{
php_stream *stream = NULL;
php_url *resource = NULL;