diff -Naur -Naru http_get/http_get.c http_get.pb/http_get.c --- http_get/http_get.c 2005-06-19 22:48:15.000000000 +0000 +++ http_get.pb/http_get.c 2009-10-22 11:23:18.000000000 +0000 @@ -17,6 +17,7 @@ #ifdef USE_SSL #include +#include #endif @@ -221,8 +222,8 @@ { int sockfd; #ifdef USE_SSL - SSL_CTX* ssl_ctx; - SSL* ssl; + SSL_CTX* ssl_ctx = NULL; + SSL* ssl = NULL; #endif char buf[20000]; int i, bytes, b, header_state, status; @@ -250,6 +251,8 @@ exit( 1 ); } } +#else + (void) protocol; #endif /* Build request buffer, starting with the GET. */ @@ -264,14 +267,13 @@ bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "User-Agent: %s\r\n", user_agent ); /* Fixed headers. */ bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "Accept: */*\r\n" ); - bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "Accept-Encoding: gzip, compress\r\n" ); bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "Accept-Language: en\r\n" ); bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "Accept-Charset: iso-8859-1,*,utf-8\r\n" ); if ( auth_token != (char*) 0 ) { /* Basic Auth info. */ char token_buf[1000]; - token_buf[b64_encode( auth_token, strlen( auth_token ), token_buf, sizeof(token_buf) )] = '\0'; + token_buf[b64_encode( (unsigned char*) auth_token, strlen( auth_token ), token_buf, sizeof(token_buf) )] = '\0'; bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "Authorization: Basic %s\r\n", token_buf ); } /* Cookies. */ @@ -284,10 +286,8 @@ if ( protocol == PROTO_HTTPS ) (void) SSL_write( ssl, buf, bytes ); else - (void) write( sockfd, buf, bytes ); -#else - (void) write( sockfd, buf, bytes ); #endif + (void) write( sockfd, buf, bytes ); /* Get lines until a blank one. */ (void) alarm( timeout ); @@ -299,10 +299,8 @@ if ( protocol == PROTO_HTTPS ) bytes = SSL_read( ssl, buf, sizeof(buf) ); else - bytes = read( sockfd, buf, sizeof(buf) ); -#else - bytes = read( sockfd, buf, sizeof(buf) ); #endif + bytes = read( sockfd, buf, sizeof(buf) ); if ( bytes <= 0 ) break; for ( b = 0; b < bytes; ++b ) @@ -400,8 +398,11 @@ } end_of_headers: /* Dump out the rest of the headers buffer. */ - ++b; - (void) write( 1, &buf[b], bytes - b ); + if (bytes > 0) + { + ++b; + (void) write( 1, &buf[b], bytes - b ); + } /* Copy the data. */ for (;;) @@ -411,10 +412,8 @@ if ( protocol == PROTO_HTTPS ) bytes = SSL_read( ssl, buf, sizeof(buf) ); else - bytes = read( sockfd, buf, sizeof(buf) ); -#else - bytes = read( sockfd, buf, sizeof(buf) ); #endif + bytes = read( sockfd, buf, sizeof(buf) ); if ( bytes == 0 ) break; if ( bytes < 0 ) @@ -574,6 +573,7 @@ static void sigcatch( int sig ) { + (void) sig; (void) fprintf( stderr, "%s: %s - timed out\n", argv0, url ); exit( 1 ); }