static int reqpersec;
static int nrequests;
static int opt_ims = 0;
+static int opt_range = 0;
static int max_connections = 64;
static time_t lifetime = 60;
static struct timeval now;
struct _request *r = data;
static unsigned char buf[READ_BUF_SZ];
int len;
- char *p;
if ((len=read(fd, buf, READ_BUF_SZ)) <= 0) {
fd_close(fd);
reqpersec++;
reply_done(int fd, void *data)
{
struct _request *r = data;
+ if (opt_range)
+ ; /* skip size checks for now */
if (r->bodysize != r->content_length)
fprintf(stderr,"ERROR: %s expected %d bytes got %d\n",
r->url, r->content_length, r->bodysize);
sprintf(buf,"Content-Length: %d\r\n", st.st_size);
strcat(msg,buf);
}
+ if (opt_range && (lrand48() & 0x03) == 0) {
+ int len;
+ int count = 0;
+ strcat(msg, "Range: bytes=");
+ while (((len = (int)lrand48()) & 0x03) == 0 || !count) {
+ const int offset = (int) lrand48();
+ if (count)
+ strcat(msg, ",");
+ switch (lrand48() & 0x03) {
+ case 0:
+ sprintf(buf, "-%d", len);
+ break;
+ case 1:
+ sprintf(buf, "%d-", offset);
+ break;
+ default:
+ sprintf(buf, "%d-%d", offset, offset+len);
+ break;
+ }
+ strcat(msg,buf);
+ count++;
+ }
+ strcat(msg,"\r\n");
+ }
strcat(msg, "\r\n");
len = strlen(msg);
if ((len2=write(s, msg, len)) != len) {
struct _request *r;
static char buf[8192];
char *t;
- int s;
if (fgets(buf, 8191, stdin) == NULL) {
printf("Done Reading URLS\n");
fd_close(0);
void
usage(void)
{
- fprintf(stderr, "usage: %s: -p port -h host -n max\n", progname);
+ fprintf(stderr, "usage: %s: [-cir] -p port -h host -n max\n", progname);
}
int
progname = strdup(argv[0]);
gettimeofday(&now, NULL);
start = last = now;
- while ((c = getopt(argc, argv, "p:h:n:icl:")) != -1) {
+ while ((c = getopt(argc, argv, "p:h:n:icrl:")) != -1) {
switch (c) {
case 'p':
proxy_port = atoi(optarg);
case 'c':
opt_checksum = 1;
break;
+ case 'r':
+ opt_range = 1;
+ break;
default:
usage();
return 1;