]> granicus.if.org Git - php/commitdiff
using the new hostconnect() for the http wrapper
authorStig Venaas <venaas@php.net>
Tue, 5 Sep 2000 15:59:08 +0000 (15:59 +0000)
committerStig Venaas <venaas@php.net>
Tue, 5 Sep 2000 15:59:08 +0000 (15:59 +0000)
main/fopen_wrappers.c

index fa7c053f4b14e328d0512f52f9a5d6538bec41fd..a9472b68bffb62aa12521e9d887185b55e301ab4 100644 (file)
@@ -42,6 +42,7 @@
 #include "ext/standard/head.h"
 #include "ext/standard/php_standard.h"
 #include "zend_compile.h"
+#include "php_network.h"
 
 #if HAVE_PWD_H
 #ifdef PHP_WIN32
@@ -476,7 +477,6 @@ static FILE *php_fopen_url_wrap_http(const char *path, char *mode, int options,
 {
        FILE *fp=NULL;
        php_url *resource=NULL;
-       struct sockaddr_in server;
        char tmp_line[512];
        char location[512];
        char hdr_line[8192];
@@ -496,24 +496,8 @@ static FILE *php_fopen_url_wrap_http(const char *path, char *mode, int options,
        if (resource->port == 0)
                resource->port = 80;
        
-       *socketd = socket(AF_INET, SOCK_STREAM, 0);
-       if (*socketd == SOCK_ERR) {
-               SOCK_FCLOSE(*socketd);
-               *socketd = 0;
-               free_url(resource);
-               return NULL;
-       }
-       server.sin_family = AF_INET;
-       
-       if (lookup_hostname(resource->host, &server.sin_addr)) {
-               SOCK_FCLOSE(*socketd);
-               *socketd = 0;
-               free_url(resource);
-               return NULL;
-       }
-       server.sin_port = htons(resource->port);
-       
-       if (connect(*socketd, (struct sockaddr *) &server, sizeof(server)) == SOCK_CONN_ERR) {
+       *socketd = hostconnect(resource->host, resource->port, SOCK_STREAM, 0);
+       if (*socketd == -1) {
                SOCK_FCLOSE(*socketd);
                *socketd = 0;
                free_url(resource);