Beispiel #1
0
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;
    }
}
Beispiel #2
0
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
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;
		}
	}
}