static void set_uri (Event_Type et, Call * c) { int len, did_wrap = 0; const char *uri; assert (et == EV_CALL_NEW && object_is_call (c)); do { if (fcurrent >= fend) { if (did_wrap) panic ("%s: %s does not contain any valid URIs\n", prog_name, param.wlog.file); did_wrap = 1; /* We reached the end of the uri list so wrap around to the beginning. If not looping, also ask for the test to stop as soon as possible (the current request will still go out, but httperf won't wait for its reply to show up). */ fcurrent = fbase; if (!param.wlog.do_loop) core_exit (); } uri = fcurrent; len = strlen (fcurrent); call_set_uri (c, uri, len); fcurrent += len + 1; } while (len == 0); if (verbose) printf ("%s: accessing URI `%s'\n", prog_name, uri); }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, n; const char *method_str; Call *call; REQ *req; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_calls_in_this_burst > 0) to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst; n = session_max_qlen (sess) - session_current_qlen (sess); if (n < to_create) to_create = n; priv->num_calls_in_this_burst += to_create; for (i = 0; i < to_create; ++i) { call = call_new (); if (!call) { sess_failure (sess); return; } /* fill in the new call: */ req = priv->current_req; if (req == NULL) panic ("%s: internal error, requests ran past end of burst\n", prog_name); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); if (req->contents_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } priv->current_req = req->next; if (DBG > 0) fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; } }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, embedded = 0; Call_Private_Data *cpriv; struct uri_list *el; Call *call; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_created > 0) { to_create = session_max_qlen (sess) - session_current_qlen (sess); embedded = 1; } for (i = 0; i < to_create && (!embedded || priv->uri_list); ++i) { ++priv->num_created; call = call_new (); if (!call) { sess_failure (sess); return; } if (embedded) { el = priv->uri_list; priv->uri_list = el->next; cpriv = CALL_PRIVATE_DATA (call); cpriv->to_free = el; call_set_uri (call, el->uri, el->uri_len); } if (verbose > 1) printf ("%s: fetching `%s'\n", prog_name, (char *)call->req.iov[IE_URI].iov_base); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; } }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int retval; const char *method_str; Call *call; REQ *req; call = call_new (); if (!call) { sess_failure (sess); return; } req = priv->current_req; if (req == NULL) panic ("%s: internal error, requests ran past end of session\n", prog_name); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); if (req->contents_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } if (DBG > 0) fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; }
static void set_uri (Event_Type et, Call * c) { char *uri; int uri_len, did_wrap = 0, range_len, input_len; const char *input_line; assert (et == EV_CALL_NEW && object_is_call (c)); do { if (fcurrent >= fend) { if (did_wrap) panic ("%s: %s does not contain any valid URIs\n", prog_name, param.wrangelog.file); did_wrap = 1; /* We reached the end of the uri list so wrap around to the beginning. If not looping, also ask for the test to stop as soon as possible (the current request will still go out, but httperf won't wait for its reply to show up). */ fcurrent = fbase; if (!param.wrangelog.do_loop) core_exit (); } input_line = fcurrent; input_len = strlen (fcurrent); /*****************************/ // int j; // while (input_line[j] != ' ') { // j++; // if (j > input_len) // { // panic ("Error: illegal format for wrangelog\n"); // } // } // // uri_len = j; uri_len = strcspn( input_line, " "); uri = fcurrent; /***************************/ int range_size = input_len - uri_len - 1; char prefix_extra_hdrs[] = "Range: bytes="; size_t prefix_size = strlen(prefix_extra_hdrs); char suffix_extra_hdrs[] = "\r\n"; size_t suffix_size = strlen(suffix_extra_hdrs); size_t extra_header_len = prefix_size + range_size + suffix_size; c->extra_header = (char*) malloc( sizeof(char) * extra_header_len); // Copy the prefix strncpy(c->extra_header, prefix_extra_hdrs, prefix_size); // Copy the range value strncpy(c->extra_header + prefix_size, fcurrent + uri_len + 1, range_size); // Copy the suffix strncpy(c->extra_header + prefix_size + range_size, suffix_extra_hdrs, suffix_size); call_set_uri (c, uri, uri_len); fcurrent += input_len + 1; call_append_request_header (c, c->extra_header,extra_header_len); } while (input_len == 0); if (verbose) printf ("%s: accessing URI `%s'\n", prog_name, uri); }
static void set_uri (Event_Type et, Call *call) { assert (et == EV_CALL_NEW && object_is_call (call)); call_set_uri (call, param.uri, uri_len); }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, n; const char *method_str; Call *call; REQ *req; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_calls_in_this_burst > 0) { to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst; } n = session_max_qlen (sess) - session_current_qlen (sess); if (n < to_create) { to_create = n; } priv->num_calls_in_this_burst += to_create; for (i = 0; i < to_create; ++i) { call = call_new (); if (!call) { sess_failure (sess); return; } /* fill in the new call: */ req = priv->current_req; if (req == NULL) { panic ("%s: internal error, requests ran past end of burst\n",prog_name); } call_set_version (call, priv->http_version); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); #ifdef UW_DYNOUT call->timelimit = req->timelimit; #endif /* UW_DYNOUT */ /* used for call stats */ call->file_size = req->file_size; if (req->cookie_len > 0) { /* add "Cookie:" header if necessary: */ call_append_request_header (call, req->cookie, req->cookie_len); } #ifdef WSESSLOG_HEADERS if (req->contents_len > 0 || req->extra_hdrs_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); if (req->contents_len > 0) { call_set_contents(call, req->contents, req->contents_len); } } #else if (req->extra_hdrs_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } #endif /* WSESSLOG_HEADERS */ #ifdef UW_CALL_STATS if (param.client.id >= 0) { sprintf (call->id_hdr, "Client-Id: %d %d\r\n", param.client.id, (int) call->id); call_append_request_header (call, call->id_hdr, strlen(call->id_hdr)); } #endif /* UW_CALL_STATS */ priv->current_req = req->next; if (DBG > 0) { fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); } retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) { return; } } }