diff -r -u siege-2.50b7/doc/siege.1 siege-2.50b7-p2/doc/siege.1 --- siege-2.50b7/doc/siege.1 Mon Jan 14 16:45:30 2002 +++ siege-2.50b7-p2/doc/siege.1 Mon Jan 21 16:01:20 2002 @@ -70,6 +70,8 @@ .TP \fB\-u URL\fR, \fB\-\-url=URL\fR URL, use this option to stress a single URL. This option overrides the URL file and stresses just the URL selected at the command line. +\fB\-H HEADER\fR, \fB\-\-header=HEADER\fR +Define a HTTP-Header that is put to every http-request. Multiple headers can be defined. .SH URL FORMAT Siege understands the following URL formats: [protocol://] [servername.domain.xxx] [:portnumber] [/directory/file] OR [protocol://] [servername.domain.xxx] [:portnumber] [/directory/file] POST field=value&field2=value2 The former URL is an implicit GET, the second obviously is a POST. If you invoke the URL on the command line with the \-u option, you should probably place the URL in quotes. Currently, it supports two protocols, http and https. If a protocol is not specified, then siege assumes http. The minimum URL requirement is this: servername. That's it. So if you're in the same domain as a server named shemp and shemp is in your host file or it is in DNS, then: "siege -u shemp" will stress http://shemp.yourdomain.net/index.html (assuming that "index.html" is the server specified index). To stress the same page using https protocol, the minimum URL requirement is this: https://shemp. That URL specification will lay siege to https://shemp.yourdomain.net/index.html .SH CONFIGURATION FILE @@ -165,6 +167,14 @@ .SH AVAILABILITY The most recent released version of siege is available by anonymous ftp from ftp.armstrong.com in the directory pub/siege. + +.SH NOTES +This version is hacked by Jukka Pihl (2002.01.21) +.TP +- You can add HTTP-headers with '-H' option (like 'MSISDN: 01239747474') +.TP +- In this version you can define place of siegerc-file by defining envrinment variable "SIEGERC". + .LP .SH SEE ALSO siege.config(1) layingsiege(1) urls_txt(1) diff -r -u siege-2.50b7/src/http.c siege-2.50b7-p2/src/http.c --- siege-2.50b7/src/http.c Mon Jan 14 16:45:41 2002 +++ siege-2.50b7-p2/src/http.c Mon Jan 21 15:48:01 2002 @@ -58,9 +58,9 @@ "Cookie: %s\015\012" "Accept: */*\015\012" "Accept-Encoding: * \015\012" - "User-Agent: %s\015\012" + "User-Agent: %s\015\012%s" "Connection: %s\015\012\015\012", - path, protocol, host, my.auth, cookie, my.uagent, keepalive + path, protocol, host, my.auth, cookie, my.uagent, my.extra, keepalive ); } else{ @@ -71,9 +71,9 @@ "Cookie: %s\015\012" "Accept: */*\015\012" "Accept-Encoding: * \015\012" - "User-Agent: %s\015\012" + "User-Agent: %s\015\012%s" "Connection: %s\015\012\015\012", - path, protocol, host, cookie, my.uagent, keepalive + path, protocol, host, cookie, my.uagent, my.extra, keepalive ); } @@ -118,12 +118,12 @@ "Cookie: %s\015\012" "Accept: */*\015\012" "Accept-Encoding: * \015\012" - "User-Agent: %s\015\012" + "User-Agent: %s\015\012%s" "Connection: %s\015\012" "Content-type: application/x-www-form-urlencoded\015\012" "Content-length: %d\015\012\015\012" "%*.*s\015\012", - path, protocol, host, my.auth, cookie, my.uagent, keepalive, len, len, len, data + path, protocol, host, my.auth, cookie, my.uagent, my.extra, keepalive, len, len, len, data ); } else{ @@ -134,12 +134,12 @@ "Cookie: %s\015\012" "Accept: */*\015\012" "Accept-Encoding: * \015\012" - "User-Agent: %s\015\012" + "User-Agent: %s\015\012%s" "Connection: %s\015\012" "Content-type: application/x-www-form-urlencoded\015\012" "Content-length: %d\015\012\015\012" "%*.*s\015\012", - path, protocol, host, cookie, my.uagent, keepalive, len, len, len, data + path, protocol, host, cookie, my.uagent, my.extra, keepalive, len, len, len, data ); } diff -r -u siege-2.50b7/src/init.c siege-2.50b7-p2/src/init.c --- siege-2.50b7/src/init.c Mon Jan 14 16:45:49 2002 +++ siege-2.50b7-p2/src/init.c Mon Jan 21 15:53:03 2002 @@ -29,6 +29,7 @@ int init_config( void ) { + char *e; char filename[256]; char buf[256]; memset( &my, 0, sizeof( struct CONFIG )); /* from setup.h */ @@ -37,7 +38,11 @@ our.shutting_down = 0; our.total_threads = 0; - snprintf( filename, sizeof( filename), "%s/.siegerc", getenv( "HOME" )); + if((e = getenv("SIEGERC")) != NULL) { + snprintf(filename, sizeof( filename), e); + } else { + snprintf( filename, sizeof( filename), "%s/.siegerc", getenv( "HOME" )); + } strcpy( my.file, SIEGE_HOME ); strcat( my.file, "/etc/urls.txt" ); @@ -47,6 +52,7 @@ my.secs = -1; my.reps = MAXREPS; my.authorize = FALSE; + my.extra[0] = 0; if( load_conf( filename ) < 0 ){ fprintf( stderr, "****************************************************\n" ); fprintf( stderr, "siege: could not open %s\n", filename ); @@ -282,6 +288,15 @@ else my.protocol = FALSE; } + + if( !strncasecmp( option, "header", 6 )){ + int ll; + if(!strchr(value,':')) joe_fatal("no ':' in http-header"); + if((strlen(value) + strlen(my.extra) + 3) > 512) joe_fatal("too many headers"); + strcat(my.extra,value); + strcat(my.extra,"\015\012"); + } + } /* end of while line=chomp_line */ return 0; diff -r -u siege-2.50b7/src/main.c siege-2.50b7-p2/src/main.c --- siege-2.50b7/src/main.c Mon Jan 14 16:45:57 2002 +++ siege-2.50b7-p2/src/main.c Mon Jan 21 15:51:54 2002 @@ -71,7 +71,8 @@ { "log", no_argument, NULL, 'l' }, { "file", required_argument, NULL, 'f' }, { "url", required_argument, NULL, 'u' }, - { "mark", required_argument, NULL, 'm' } + { "mark", required_argument, NULL, 'm' }, + { "header", required_argument, NULL, 'H' } }; /** @@ -127,6 +128,7 @@ puts(" -m, --mark=\"text\" MARK, mark the log file with a string separator." ); puts(" -d, --delay=NUM Time DELAY, random delay between 1 and num designed" ); puts(" to simulate human activity. Default value is 3" ); + puts(" -H, --header=NUM Add a header to request (can be many)" ); /** * our work is done, exit nicely */ @@ -142,7 +144,7 @@ parse_cmdline( int argc, char *argv[] ) { int c = 0; - while ((c = getopt_long (argc, argv, "VhvCDlibr:t:f:d:c:u:m:", long_options, (int *)0)) != EOF){ + while ((c = getopt_long (argc, argv, "VhvCDlibr:t:f:d:c:u:m:H:", long_options, (int *)0)) != EOF){ switch( c ){ case 'V': display_version( TRUE ); @@ -193,6 +195,18 @@ case 'u': my.url = (char*)strdup( optarg ); break; + + case 'H': + { + int ll; + if(!strchr(optarg,':')) joe_fatal("no ':' in http-header"); + if((strlen(optarg) + strlen(my.extra) + 3) > 512) + joe_fatal("too many headers"); + strcat(my.extra,optarg); + strcat(my.extra,"\015\012"); + } + break; + } /** end of switch( c ) **/ } /** end of while c = getopt_long **/ } /** end of parse_cmdline **/ diff -r -u siege-2.50b7/src/setup.h siege-2.50b7-p2/src/setup.h --- siege-2.50b7/src/setup.h Mon Jan 14 16:45:47 2002 +++ siege-2.50b7-p2/src/setup.h Mon Jan 21 15:46:01 2002 @@ -168,6 +168,7 @@ int authorize; /* WWW-Authenticate boolean, require auth */ int keepalive; /* boolean, connection keep-alive value */ int signaled; /* timed based testing notification bool. */ + char extra[512]; /* extra headers */ }; struct STATUS