Created
April 10, 2013 08:13
-
-
Save debility-zz/5352768 to your computer and use it in GitHub Desktop.
http_loadでUser-Agentを指定できるようにざっくり修正してみた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- http_load.c.orig 2013-04-10 16:31:14.641380516 +0900 | |
+++ http_load.c 2013-04-10 17:07:36.480199674 +0900 | |
@@ -183,6 +183,8 @@ | |
static char* cipher = (char*) 0; | |
#endif | |
+char* user_agent; | |
+ | |
/* Forwards. */ | |
static void usage( void ); | |
static void read_url_file( char* url_file ); | |
@@ -257,6 +259,7 @@ | |
idle_secs = IDLE_SECS; | |
start = START_NONE; | |
end = END_NONE; | |
+ user_agent = VERSION; | |
while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) | |
{ | |
if ( strncmp( argv[argn], "-checksum", strlen( argv[argn] ) ) == 0 ) | |
@@ -358,6 +361,8 @@ | |
*colon = '\0'; | |
} | |
} | |
+ else if ( strncmp( argv[argn], "-user-agent", strlen( argv[argn] ) ) == 0 && argn + 1 < argc ) | |
+ user_agent = argv[++argn]; | |
else | |
usage(); | |
++argn; | |
@@ -507,7 +512,7 @@ | |
usage( void ) | |
{ | |
(void) fprintf( stderr, | |
- "usage: %s [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file]\n", argv0 ); | |
+ "usage: %s [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file] [-user-agent user_agent]\n", argv0 ); | |
#ifdef USE_SSL | |
(void) fprintf( stderr, | |
" [-cipher str]\n" ); | |
@@ -1025,7 +1030,7 @@ | |
&buf[bytes], sizeof(buf) - bytes, "Host: %s\r\n", | |
urls[url_num].hostname ); | |
bytes += snprintf( | |
- &buf[bytes], sizeof(buf) - bytes, "User-Agent: %s\r\n", VERSION ); | |
+ &buf[bytes], sizeof(buf) - bytes, "User-Agent: %s\r\n", user_agent ); | |
bytes += snprintf( &buf[bytes], sizeof(buf) - bytes, "\r\n" ); | |
/* Send the request. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment