You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2006/04/18 00:33:02 UTC
svn commit: r394795 - in /httpd/test/trunk/flood: CHANGES config.h.in
flood_profile.h flood_round_robin.c
Author: jerenkrantz
Date: Mon Apr 17 15:32:59 2006
New Revision: 394795
URL: http://svn.apache.org/viewcvs?rev=394795&view=rev
Log:
Add extraheader, payloadfile attribute to url element; also support custom HTTP
methods.
(This lets flood passably mimic WebDAV requests.)
* flood_round_robin.c
(url_t): Add method_string, extra_headers fields.
(round_robin_create_req): Add short-cut to ->extra_headers field; simplify
request creation based on methods and add in extra headers if present;
(parse_xml_url_info): Set method_string on all variants; support
payloadfile attribute to load the entire payload from a file; include any
extra headers - delimit multiple headers with ; for now.
(round_robin_get_next_url): Fix whitespace.
* flood_profile.h
(method_e): Denote 'other' methods.
* config.h.in
(XML_URLLIST_PAYLOAD_FILE, XML_URLLIST_EXTRA_HEADERS): Define.
Modified:
httpd/test/trunk/flood/CHANGES
httpd/test/trunk/flood/config.h.in
httpd/test/trunk/flood/flood_profile.h
httpd/test/trunk/flood/flood_round_robin.c
Modified: httpd/test/trunk/flood/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/flood/CHANGES?rev=394795&r1=394794&r2=394795&view=diff
==============================================================================
--- httpd/test/trunk/flood/CHANGES (original)
+++ httpd/test/trunk/flood/CHANGES Mon Apr 17 15:32:59 2006
@@ -1,5 +1,13 @@
Changes since 1.0:
+* Add extraheader attribute to url's to allow custom headers to be set.
+ [Justin Erenkrantz]
+
+* Add payloadfile attribute to url's to allow the body to be read from a file.
+ [Justin Erenkrantz]
+
+* Support custom HTTP methods. [Justin Erenkrantz]
+
* Fix corruption when we have multiple usefarmer's without a count.
[Justin Erenkrantz]
Modified: httpd/test/trunk/flood/config.h.in
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/flood/config.h.in?rev=394795&r1=394794&r2=394795&view=diff
==============================================================================
--- httpd/test/trunk/flood/config.h.in (original)
+++ httpd/test/trunk/flood/config.h.in Mon Apr 17 15:32:59 2006
@@ -23,8 +23,10 @@
#define XML_URLLIST_METHOD_POST "post"
#define XML_URLLIST_METHOD_HEAD "head"
#define XML_URLLIST_PAYLOAD "payload"
-#define XML_URLLIST_CONTENT_TYPE "content-type"
+#define XML_URLLIST_PAYLOAD_FILE "payloadfile"
#define XML_URLLIST_PAYLOAD_TEMPLATE "payloadtemplate"
+#define XML_URLLIST_CONTENT_TYPE "content-type"
+#define XML_URLLIST_EXTRA_HEADERS "extraheader"
#define XML_URLLIST_REQUEST_TEMPLATE "requesttemplate"
#define XML_URLLIST_RESPONSE_TEMPLATE "responsetemplate"
#define XML_URLLIST_RESPONSE_SCRIPT "responsescript"
Modified: httpd/test/trunk/flood/flood_profile.h
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/flood/flood_profile.h?rev=394795&r1=394794&r2=394795&view=diff
==============================================================================
--- httpd/test/trunk/flood/flood_profile.h (original)
+++ httpd/test/trunk/flood/flood_profile.h Mon Apr 17 15:32:59 2006
@@ -47,7 +47,8 @@
enum method_e {
GET,
POST,
- HEAD
+ HEAD,
+ OTHER
};
typedef enum method_e method_e;
Modified: httpd/test/trunk/flood/flood_round_robin.c
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/flood/flood_round_robin.c?rev=394795&r1=394794&r2=394795&view=diff
==============================================================================
--- httpd/test/trunk/flood/flood_round_robin.c (original)
+++ httpd/test/trunk/flood/flood_round_robin.c Mon Apr 17 15:32:59 2006
@@ -69,8 +69,10 @@
typedef struct {
char *url;
method_e method;
+ const char *method_string;
char *payload;
char *contenttype;
+ char *extra_headers;
apr_int64_t predelay;
apr_int64_t predelayprecision;
apr_int64_t postdelay;
@@ -216,7 +218,7 @@
{
round_robin_profile_t *p;
char *cookies, *path;
- char *enc_credtls, *credtls, *authz_hdr = NULL;
+ char *enc_credtls, *credtls, *authz_hdr = NULL, *extra_hdr = NULL;
cookie_t *cook;
p = (round_robin_profile_t*)profile;
@@ -262,6 +264,10 @@
}
}
+ if (p->url[p->current_url].extra_headers) {
+ extra_hdr = p->url[p->current_url].extra_headers;
+ }
+
if (p->proxy_url != NULL) {
path = apr_pstrcat(r->pool, r->parsed_uri->scheme, "://",
r->parsed_uri->hostinfo,
@@ -274,78 +280,75 @@
switch (r->method)
{
case GET:
- r->rbuf = apr_psprintf(r->pool,
- "GET %s%s%s HTTP/1.1" CRLF
- "User-Agent: Flood/" FLOOD_VERSION CRLF
- "Connection: %s" CRLF
- "Host: %s" CRLF
- "%s"
- "%s" CRLF,
- path,
- r->parsed_uri->query ? "?" : "",
- r->parsed_uri->query ? r->parsed_uri->query : "",
- r->keepalive ? "Keep-Alive" : "Close",
- r->parsed_uri->hostinfo,
- authz_hdr ? authz_hdr : "",
- cookies);
- r->rbuftype = POOL;
- r->rbufsize = strlen(r->rbuf);
- break;
case HEAD:
r->rbuf = apr_psprintf(r->pool,
- "HEAD %s%s%s HTTP/1.1" CRLF
+ "%s %s%s%s HTTP/1.1" CRLF
"User-Agent: Flood/" FLOOD_VERSION CRLF
"Connection: %s" CRLF
"Host: %s" CRLF
- "%s"
- "%s" CRLF,
- path,
+ "%s" /* Extra headers */
+ "%s" /* Authz */
+ "%s" /* Cookies */
+ CRLF, /* End of HTTP request headers */
+ p->url[p->current_url].method_string,
+ path,
r->parsed_uri->query ? "?" : "",
r->parsed_uri->query ? r->parsed_uri->query : "",
r->keepalive ? "Keep-Alive" : "Close",
r->parsed_uri->hostinfo,
+ extra_hdr ? extra_hdr : "",
authz_hdr ? authz_hdr : "",
cookies);
r->rbuftype = POOL;
r->rbufsize = strlen(r->rbuf);
break;
case POST:
- /* FIXME */
+ case OTHER:
if (r->payload) {
r->rbuf = apr_psprintf(r->pool,
- "POST %s%s%s HTTP/1.1" CRLF
+ "%s %s%s%s HTTP/1.1" CRLF
"User-Agent: Flood/" FLOOD_VERSION CRLF
"Connection: %s" CRLF
"Host: %s" CRLF
"Content-Length: %d" CRLF
- "Content-type: %s" CRLF
- "%s"
- "%s" CRLF
- "%s",
+ "Content-Type: %s" CRLF
+ "%s" /* Extra headers */
+ "%s" /* Authz */
+ "%s" /* Cookies */
+ CRLF /* End of HTTP request headers */
+ "%s" /* Body */,
+ p->url[p->current_url].method_string,
path,
r->parsed_uri->query ? "?" : "",
- r->parsed_uri->query ? r->parsed_uri->query : "",
+ r->parsed_uri->query ?
+ r->parsed_uri->query : "",
r->keepalive ? "Keep-Alive" : "Close",
r->parsed_uri->hostinfo,
r->payloadsize,
- r->contenttype ? r->contenttype : "application/x-www-form-urlencoded",
+ r->contenttype ? r->contenttype :
+ "application/x-www-form-urlencoded",
+ extra_hdr ? extra_hdr : "",
authz_hdr ? authz_hdr : "",
cookies,
(char*)r->payload);
} else { /* There is no payload, but it's still a POST */
r->rbuf = apr_psprintf(r->pool,
- "POST %s%s%s HTTP/1.1" CRLF
+ "%s %s%s%s HTTP/1.1" CRLF
"User-Agent: Flood/" FLOOD_VERSION CRLF
"Connection: %s" CRLF
"Host: %s" CRLF
-
- "%s"
- "%s" CRLF "",
+ "%s" /* Extra headers */
+ "%s" /* Authz */
+ "%s" /* Cookies */
+ CRLF /* End of HTTP request headers */
+ "" /* No body */,
+ p->url[p->current_url].method_string,
path,
r->parsed_uri->query ? "?" : "",
r->parsed_uri->query ? r->parsed_uri->query : "",
r->keepalive ? "Keep-Alive" : "Close",
r->parsed_uri->hostinfo,
+ extra_hdr ? extra_hdr : "",
authz_hdr ? authz_hdr : "",
cookies);
}
@@ -386,29 +389,82 @@
{
if (strncasecmp(attr->name, XML_URLLIST_METHOD,
FLOOD_STRLEN_MAX) == 0) {
- if (strncasecmp(attr->value, XML_URLLIST_METHOD_POST, 4) == 0)
+ if (strncasecmp(attr->value, XML_URLLIST_METHOD_POST, 4) == 0) {
url->method = POST;
+ url->method_string = "POST";
+ }
else if (strncasecmp(attr->value, XML_URLLIST_METHOD_HEAD,
4) == 0)
+ {
url->method = HEAD;
+ url->method_string = "HEAD";
+ }
else if (strncasecmp(attr->value, XML_URLLIST_METHOD_GET,
- 3) == 0)
+ 3) == 0) {
url->method = GET;
+ url->method_string = "GET";
+ }
else {
- apr_file_printf(local_stderr,
- "Attribute %s has invalid value %s.\n",
- XML_URLLIST_METHOD, attr->value);
- return APR_EGENERAL;
+ url->method = OTHER;
+ url->method_string = apr_pstrdup(pool, attr->value);
}
}
else if (strncasecmp(attr->name, XML_URLLIST_PAYLOAD,
FLOOD_STRLEN_MAX) == 0) {
url->payload = (char*)attr->value;
}
- else if (strncasecmp(attr->name,XML_URLLIST_CONTENT_TYPE,
- FLOOD_STRLEN_MAX) == 0) {
- url->contenttype = (char*)attr->value;
- }
+ else if (strncasecmp(attr->name, XML_URLLIST_PAYLOAD_FILE,
+ FLOOD_STRLEN_MAX) == 0) {
+ apr_status_t status;
+ const char *fname;
+ apr_finfo_t finfo;
+ apr_file_t *file;
+ apr_size_t len;
+
+ fname = attr->value;
+
+ status = apr_stat(&finfo, fname, APR_FINFO_MIN, pool);
+ if (status != APR_SUCCESS)
+ return status;
+
+ status = apr_file_open(&file, fname, APR_READ, APR_OS_DEFAULT,
+ pool);
+ if (status != APR_SUCCESS)
+ return status;
+
+ url->payload = apr_palloc(pool, finfo.size + 1);
+
+ status = apr_file_read_full(file, url->payload, finfo.size,
+ &len);
+ if (len != finfo.size)
+ return status;
+
+ apr_file_close(file);
+ }
+ else if (strncasecmp(attr->name,XML_URLLIST_CONTENT_TYPE,
+ FLOOD_STRLEN_MAX) == 0) {
+ url->contenttype = (char*)attr->value;
+ }
+ else if (strncasecmp(attr->name,XML_URLLIST_EXTRA_HEADERS,
+ FLOOD_STRLEN_MAX) == 0) {
+ char *last, *header;
+
+ header = apr_strtok((char*)attr->value, ";", &last);
+ while (header) {
+ apr_collapse_spaces(header, header);
+ if (url->extra_headers) {
+ url->extra_headers = apr_pstrcat(pool,
+ url->extra_headers,
+ header, CRLF, NULL);
+ }
+ else {
+ url->extra_headers = apr_pstrcat(pool,
+ header, CRLF, NULL);
+ }
+
+ header = apr_strtok(NULL, ";", &last);
+ }
+ }
else if (strncasecmp(attr->name, XML_URLLIST_PREDELAY,
FLOOD_STRLEN_MAX) == 0) {
char *endptr;
@@ -816,7 +872,7 @@
if (rp->url[rp->current_url].contenttype)
{
r->contenttype = parse_param_string(rp, rp->url[rp->current_url].contenttype);
- r->contenttypesize = strlen(r->contenttype);
+ r->contenttypesize = strlen(r->contenttype);
}
/* If they want a sleep, do it now. */