summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2002-09-07 15:55:04 +0000
committerSterling Hughes <sterling@php.net>2002-09-07 15:55:04 +0000
commitce686a63de1de578f6110c9688a41ffd8a725f38 (patch)
tree0fc58542211357f4477b09695e202b0a3992c1f2
parent91df221ab7d1b42b3060e99b37036e1b59a5f975 (diff)
downloadphp-git-ce686a63de1de578f6110c9688a41ffd8a725f38.tar.gz
commit the correct/up-to-date version
-rw-r--r--ext/standard/http_fopen_wrapper.c94
1 files changed, 49 insertions, 45 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index e3f2db4c52..e0a817a6d5 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -18,12 +18,14 @@
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
-/* $Id$ */
+/* $Id$ */
#include "php.h"
#include "php_globals.h"
#include "php_streams.h"
#include "php_network.h"
+#include "php_ini.h"
+#include "ext/standard/basic_functions.h"
#include <stdio.h>
#include <stdlib.h>
@@ -199,8 +201,8 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
php_stream_write(stream, scratch, strlen(scratch));
if (context &&
- php_stream_context_get_option(context, "http", "user_agent", (zval **) &ua_zval) == FAILURE &&
- php_stream_context_get_option(context, "https", "user_agent", (zval **) &ua_zval) == FAILURE) {
+ php_stream_context_get_option(context, "http", "user_agent", (zval **) &ua_zval) == FAILURE &&
+ php_stream_context_get_option(context, "https", "user_agent", (zval **) &ua_zval) == FAILURE) {
ua_str = Z_STRVAL_PP(ua_zval);
} else if (BG(user_agent)) {
ua_str = BG(user_agent);
@@ -225,7 +227,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
}
}
- php_stream_write_string(stream, "\r\n");
+ php_stream_write(stream, "\r\n", sizeof("\r\n")-1);
location[0] = '\0';
@@ -270,64 +272,66 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
}
}
- /* read past HTTP headers */
+ if( reqok ) {
+ /* read past HTTP headers */
- http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE);
+ http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE);
- while (!body && !php_stream_eof(stream)) {
+ while (!body && !php_stream_eof(stream)) {
- if (php_stream_gets(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL) {
- char *p;
- int found_eol = 0;
- int http_header_line_length;
+ if (php_stream_gets(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL) {
+ char *p;
+ int found_eol = 0;
+ int http_header_line_length;
- http_header_line[HTTP_HEADER_BLOCK_SIZE-1] = '\0';
- p = http_header_line;
- while(*p) {
- while(*p == '\n' || *p == '\r') {
- *p = '\0';
- p--;
- found_eol = 1;
+ http_header_line[HTTP_HEADER_BLOCK_SIZE-1] = '\0';
+ p = http_header_line;
+ while(*p) {
+ while(*p == '\n' || *p == '\r') {
+ *p = '\0';
+ p--;
+ found_eol = 1;
+ }
+ if (found_eol)
+ break;
+ p++;
}
- if (found_eol)
- break;
- p++;
- }
- http_header_line_length = p-http_header_line+1;
+ http_header_line_length = p-http_header_line+1;
- if (!strncasecmp(http_header_line, "Location: ", 10)) {
- strlcpy(location, http_header_line + 10, sizeof(location));
- } else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) {
- php_stream_notify_info(context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0);
- } else if (!strncasecmp(http_header_line, "Content-Length: ", 16)) {
- file_size = atoi(http_header_line + 16);
- php_stream_notify_file_size(context, file_size, http_header_line, 0);
- }
+ if (!strncasecmp(http_header_line, "Location: ", 10)) {
+ strlcpy(location, http_header_line + 10, sizeof(location));
+ } else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) {
+ php_stream_notify_info(context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0);
+ } else if (!strncasecmp(http_header_line, "Content-Length: ", 16)) {
+ file_size = atoi(http_header_line + 16);
+ php_stream_notify_file_size(context, file_size, http_header_line, 0);
+ }
+ if (http_header_line[0] == '\0')
+ body = 1;
+ else {
+ zval *http_header;
- if (http_header_line[0] == '\0')
- body = 1;
- else {
- zval *http_header;
-
- MAKE_STD_ZVAL(http_header);
+ MAKE_STD_ZVAL(http_header);
- ZVAL_STRINGL(http_header, http_header_line, http_header_line_length, 1);
+ ZVAL_STRINGL(http_header, http_header_line, http_header_line_length, 1);
- zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_header, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_header, sizeof(zval *), NULL);
+ }
}
+ else
+ break;
}
- else
- break;
- }
-
- if (!reqok) {
-
+ }
+
+ if (!reqok) {
if (location[0] != '\0')
php_stream_notify_info(context, PHP_STREAM_NOTIFY_REDIRECTED, location, 0);
php_stream_close(stream);
stream = NULL;
+ zval_dtor(response_header);
+ FREE_ZVAL(response_header);
if (location[0] != '\0') {