Index: put.c =================================================================== RCS file: /cvsroot/xenofarm/xenofarm/client/put.c,v retrieving revision 1.14 diff -u -r1.14 put.c --- put.c 12 Jan 2003 21:14:16 -0000 1.14 +++ put.c 16 Nov 2003 17:25:49 -0000 @@ -54,7 +54,7 @@ void put_file( char *url, int len ) { int i, port=80, fd; - char *host, *file, *id, buffer[4711], buffer2[1024], *p; + char *host, *file, *id, buffer[4711], buffer2[1024], *p, *proxy, *realhost; struct hostent *hent; struct sockaddr_in addr; if( strncmp( url, "http://", 7 ) ) @@ -62,14 +62,32 @@ printf("Only HTTP urls are supported\n"); exit(1); } + + proxy=getenv("http_proxy"); + id = 0; - host = url + 7; - for( i = 0; i<strlen(host); i++ ) - if( host[i] == '/' ) - { - file = host+i+1; - host[i]=0; - } + if(strlen(proxy)>7) + { + host = proxy + 7; + realhost = url + 7; + for( i = 0; i<strlen(realhost); i++ ) + if( realhost[i] == '/' ) + { + file = realhost+i+1; + realhost[i]=0; + } + } + else + { + host = url + 7; + + for( i = 0; i<strlen(host); i++ ) + if( host[i] == '/' ) + { + file = host+i+1; + host[i]=0; + } + }
for( i = 0; i<strlen(host); i++ ) if( host[i] == '@' ) @@ -88,6 +106,8 @@ break; }
+ printf("Proxy: %s\n", proxy ); + printf("Realhost: %s\n", realhost ); printf("Host: %s\n", host ); printf("File: %s\n", file ); printf("Port: %d\n", port ); @@ -148,16 +168,26 @@ printf("sending request.." ); fflush(stdout);
- sprintf( buffer, + if(strlen(proxy)>7) + sprintf( buffer, + "PUT http://%s/%s HTTP/1.0\r\n" + "Host: %s\r\n%s" + "User-Agent: simple-put\r\n" + "Content-Type: application/octet-stream\r\n" + "Content-Length: %d\r\n" + "\r\n", + realhost, file, realhost, buffer2, len ); + else + sprintf( buffer, "PUT /%s HTTP/1.0\r\n" "Host: %s:%d\r\n%s" "User-Agent: simple-put\r\n" "Content-Type: application/octet-stream\r\n" "Content-Length: %d\r\n" "\r\n", - file, host, port, buffer2, len );
+ printf("Request:\n%s\n", buffer);
i = strlen(buffer); p = buffer;