]> granicus.if.org Git - php/commitdiff
Fix potential bug in http:// proxy support.
authorSara Golemon <pollita@php.net>
Fri, 30 Jan 2004 00:24:18 +0000 (00:24 +0000)
committerSara Golemon <pollita@php.net>
Fri, 30 Jan 2004 00:24:18 +0000 (00:24 +0000)
Some proxy servers require entire URI be sent in request string.

Add context option "http"/"request_fulluri" to allow this behavior.

NEWS
ext/standard/http_fopen_wrapper.c

diff --git a/NEWS b/NEWS
index 122b4af4f6c4d0e069686ad1ef320e30303fa549..ab6bd2fae976f1c5c6ef43072c53d157ee68a58a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,8 @@ PHP                                                                        NEWS
 - Fixed bug #24608 (__set not triggered when overloading with array).
   (Stanislav)
 - Fixed bug #24243 (enabling browscap causes segfault). (Wez)
+- Added context option "http"/"request_fulluri" to send entire URI in request.
+  Required format for some proxies. (Sara)
 - Added third optional parameter 'strict' to array_keys(). Works like the
   'strict' parameter of in_array(). Feature request #24258. (Andrey)
 
index 00cd658570904c0c263ab1b52fff17041c6e324d..8d21d2485e4d881c84f818bba077e2facdced905 100644 (file)
@@ -105,7 +105,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
        size_t chunk_size = 0, file_size = 0;
        int eol_detect = 0;
        char *transport_string, *errstr = NULL;
-       int transport_len, have_header = 0;
+       int transport_len, have_header = 0, request_fulluri = 0;
 
        if (redirect_max < 1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Circular redirect, aborting.");
@@ -189,16 +189,33 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
                strcpy(scratch, "GET ");
        }
 
-       /* file */
-       if (resource->path && *resource->path)
-               strlcat(scratch, resource->path, scratch_len);
-       else
-               strlcat(scratch, "/", scratch_len);
+       /* Should we send the entire path in the request line, default to no. */
+       if (context &&
+               php_stream_context_get_option(context, "http", "request_fulluri", &tmpzval) == SUCCESS) {
+               SEPARATE_ZVAL(tmpzval);
+               convert_to_boolean_ex(tmpzval);
+               request_fulluri = Z_BVAL_PP(tmpzval) ? 1 : 0;
+               zval_ptr_dtor(tmpzval);
+       }
+
+       if (request_fulluri) {
+               /* Ask for everything */
+               strcat(scratch, path);
+       } else {
+               /* Send the traditional /path/to/file?query_string */
 
-       /* query string */
-       if (resource->query)    {
-               strlcat(scratch, "?", scratch_len);
-               strlcat(scratch, resource->query, scratch_len);
+               /* file */
+               if (resource->path && *resource->path) {
+                       strlcat(scratch, resource->path, scratch_len);
+               } else {
+                       strlcat(scratch, "/", scratch_len);
+               }
+
+               /* query string */
+               if (resource->query)    {
+                       strlcat(scratch, "?", scratch_len);
+                       strlcat(scratch, resource->query, scratch_len);
+               }
        }
 
        /* protocol version we are speaking */